简体   繁体   English

Xpath无法运行(在Eclipse中),但可以在Debug模式以及Selenium IDE上运行

[英]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. 这样做是因为您不等待新页面加载或发生任何ajax。 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. 它也可以在Selenium IDE中工作,因为它没有JUnit运行器快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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