我曾尝试从 Eclipse 本地运行 Gradle 脚本,它已成功运行。但是当我尝试通过创建“作业”从 Jenkins 运行时。无论我在哪里使用 ,都会收到此错误显式等待 在我的 Selenium 代码中
帮我摆脱它。
提前致谢。
最佳答案
此错误消息...
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for element to be clickable: Proxy element for: DefaultElementLocator 'By.id: user email' (tried for 500 second(s) with 500 milliseconds interval)
...意味着 超时异常 在尝试单击诱导 WebDriverWait 的元素时引发。
元素的相关 HTML 以及您的代码试验将帮助我们以更好的方式分析问题。但是,Locator Strategy作为
'By.id: user email'
对我来说看起来不正确。解决方案
作为解决方案,您可以尝试以下任一解决方案:
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("#user"))).click();
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(@id,'user')]"))).click();
关于selenium - 从 Jenkins 运行脚本时获取 "Timeout"和 "Unable to locate element",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59479150/