gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 08:39:19 24 4
gpt4 key购买 nike

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"));

结果:

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

最佳答案

什么是

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

不要等待新页面加载或任何 ajax 发生。如果有事情发生,那么你需要等待。它在 Debug模式下工作的原因是因为您正在慢慢地逐步执行每个步骤(因此有足够的时间发生任何事情)。它也可以在 Selenium IDE 中工作,因为它不如 JUnit 运行器快。

关于java - Xpath 无法运行(在 Eclipse 中),但可以在 Debug模式以及 Selenium IDE 下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5675180/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com