2015-05-13 34 views

回答

4

從這樣的回答:

How to handle authentication popup with Selenium WebDriver using Java

的警報方法,authenticateUsing(),您可以跳過HTTP基本身份驗證對話框。

WebDriverWait wait = new WebDriverWait(driver, 10); 
Alert alert = wait.until(ExpectedConditions.alertIsPresent()); 
alert.authenticateUsing(new UserAndPassword("USERNAME", "PASSWORD")); 

authenticateUsing()方法仍然是目前處於測試階段,但我認爲這將是硒3.0的一部分,當它終於發佈了。

+0

這看起來像我的Java – Vanatomas

+0

我相信Selenium的Ruby版本可用,並且似乎與最新版本的Selenium(不是Watir)是同步的:https://code.google.com/p/ selenium/wiki/RubyBindings。該代碼將與Java方法類似。 – djangofan