尝试这个:
driver.manage().deleteAllCookies();
driver.get("https://testersworld.com/");
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
或者
driver.manage().deleteAllCookies();
driver.get("https://testersworld.com/");
Thread.sleep(1000);
或在登录页面上选择定位器(例如输入登录(电子邮件)字段):
String cssLocator=..blablabla...;
并使用fluentWait机制:
public WebElement fluentWait(final By locator){
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(
new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
}
);
return foo; } ;
fluentWait(By.cssSelector(cssLocator));