Possible Duplicate:
XPATH or css in selenium RC
I am trying to automate the below scenario in selenium rc using java:
1.open google page 2.开发者_如何学编程enter software in search text box 3.click on search button 4.from the resultant google result, click on the first link
I am trying to use xpath or css for clicking on link, but unable to succeed. the same xpath and css work fine in selenium ide but fail in rc
can someone please help me and try to automate the above scenario and please share the code.
Thanks for your time
Try the below code:
public class SampleTest extends SeleneseTestCase{ @Test public void sampleTest() throws Exception { setUp("http://www.google.com","*iexplore"); selenium.windowMaximize(); selenium.windowFocus(); selenium.open("/"); selenium.type("q", "Software"); selenium.click("btnG"); selenium.waitForPageToLoad(""); for (int second = 0;; second++) { if (second >= 60) fail("timeout"); try { if (selenium.isElementPresent("link=Computer software - Wikipedia, the free encyclopedia")) break; } catch (Exception e) {} Thread.sleep(1000); }
selenium.click("link=Computer software - Wikipedia, the free encyclopedia");
}
}
精彩评论