我正在使用selenium webdriver和Java来自动化网页
当我输入url时,我将看到要求身份验证对话框。
我可以通过配置配置文件输入用户名和密码,但无法单击确定按钮
注意:无法获取ok按钮属性,因此无法使用以下代码
import org.openqa.selenium.Keys
WebElement.sendKeys(Keys.RETURN);有没有其他方法可以通过webdriver点击ok按钮?
发布于 2015-10-29 03:53:01
您需要将其作为一个警告框来处理,等待弹出窗口出现,然后单击OK。
下面的代码最多等待10秒,直到弹出窗口出现,然后单击OK接受弹出窗口。尽管等待是可选的。
new WebDriverWait(driver, 10).until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();https://stackoverflow.com/questions/33387626
复制相似问题