Note that there are some explanatory texts on larger screens.

plurals
  1. POXPath or CSS in Selenium RC with Java is not working
    primarykey
    data
    text
    <p>I am trying to automate the following scenario with selenium RC:</p> <ol> <li>Open Google home page and enter "Software" in search box and then click on search button.</li> <li>Click on the first link of multiple links retrieved by Google search.</li> </ol> <p>As I don't see either name or id attributes for these links and as this link's content is dynamic, I am trying to use XPath or CSS. </p> <p>From Firebug, I got XPath and also CSS by right clicking then copy XPath, copy CSS.</p> <pre><code>XPATH:/html/body/div[2]/div/div/div[6]/div[2]/div/div[2]/div/ol/li[1]/div/span/h3/a CSS:html body#gsr div#main div div#cnt div#nr_container div#center_col div#res.med div#search div#ires ol#rso li.g div.vsc span.tl h3.r a.l </code></pre> <p>I tried entering above XPath in selenium IDE in target and find button. It worked fine but when I use the above XPath or CSS in selenium RC as:</p> <pre><code>selenium.click("xpath=//html/body/div[2]/div/div/div[6]/div[2]/div/div[2]/div/ol/li[1]/div/span/h3/a"); selenium.click("css=html body#gsr div#main div div#cnt div#nr_container div#center_col div#res.med div#search div#ires ol#rso li.g div.vsc span.tl h3.r a.l"); </code></pre> <p>Both the above lines are not working and give an error. Please suggest.</p> <p>My code is as below:</p> <pre><code>package Eclipse_Package; import com.thoughtworks.selenium.*; import org.junit.*; //import org.junit.Before; //import org.junit.Test; import java.util.regex.Pattern; public class Selenium_SX extends SeleneseTestCase { // public class Jun3 @Before public void setUp() { selenium = new DefaultSelenium("localhost", 4444, "*firefox3 C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe", "http://www.google.co.in/"); selenium.start(); } // C:\Program Files (x86)\Mozilla Firefox\ @SuppressWarnings("deprecation") @Test public void test() { selenium.open("http://www.google.com"); selenium.windowMaximize(); // selenium.waitForPageToLoad("5000"); // selenium.type("id=acpro_inp3", "selenium"); selenium.type("q", "software"); selenium.click("btnG"); selenium.waitForPageToLoad("7000"); // selenium.fireEvent("Selenium web application testing system", "click"); // selenium.click("link=Selenium web application testing system"); // selenium.click("xpath=//html/body/div[2]/div/div/div[6]/div[2]/div/div[2]/div/ol/li[1]/div/span/h3/a"); selenium.click("xpath=(//a[class=\"li[1]\"])[1]"); // selenium.click("css=//div['span.tl h3.r a.l']"); selenium.waitForPageToLoad("15000"); } @After public void tearDown() { selenium.stop(); } // public static void main(String args[])throws Exception{ // Selenium_SX sx=new Selenium_SX(); // sx.setUp(); // sx.test(); // sx.tearDown(); // } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload