我在代码的最后一行出现错误
wd.get("https://www.thehost.com/profile.php");
WebDriverWait wait = new WebDriverWait(wd, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[value='a_working_locator']"))); //line 224
wd.findElement(By.cssSelector("input[value='a_working_locator']")).click(); //line 225
错误
org.openqa.selenium.TimeoutException:之后的超时加载页面 5000ms驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver Session ID:78736d2b-3c64-4bec-a205-2ceb16ad8680 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) ... org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83) 在main.FirefoxHeadlessServer.run(FirefoxHeadlessServer.java:225)处 main.FirefoxHeadlessServer.main(FirefoxHeadlessServer.java:154)
如果ExpectedConditions在第224行然后在第225行是真的那么我会得到错误吗?
答案 0 :(得分:0)
As you are trying to invoke click()
on the same element after invoking WebDriverWait instead of the clause visibilityOfElementLocated
use the clause elementToBeClickable
as follows :
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input[value='a_working_locator']"))).click();