简体   繁体   中英

Xpath does not work running (in eclipse) but working on Debug mode as well as Selenium IDE

selenium.type("search-query", "case");
selenium.click("//div[@id='advanced-search-box']/a[1]");
selenium.click("//table[@id='search-results-table']/tbody/tr[*]/td[2]/a[@class='result-name']");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("case"));

Result:

com.thoughtworks.selenium.SeleniumException: ERROR: Element //table[@id='search-results-table']/tbody/tr[*]/td[2]/a[@class='result-name'] not found

What does

selenium.click("//div[@id='advanced-search-box']/a[1]");

do as you are not waiting for a new page to load, or any ajax to happend. If something is happening then you need to wait for it. The reason it would work in debug mode is because you are slowly stepping over each step (and thus there is enough time for anything to happen). It would also work in Selenium IDE because it is not as faster as the JUnit runner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM