1
我使用Selenium和Ruby。我必須在需要認證的頁面之間切換。 最初我用URL輸入用戶名和密碼。使用Selenium會出現幾次「Basic Authentication」彈出窗口
http://username:[email protected]/page
然而,情侶步驟後,當我重定向到另一個網頁,仍然有再次驗證彈出。
我將如何再次傳遞用戶名/密碼?
我使用Selenium和Ruby。我必須在需要認證的頁面之間切換。 最初我用URL輸入用戶名和密碼。使用Selenium會出現幾次「Basic Authentication」彈出窗口
http://username:[email protected]/page
然而,情侶步驟後,當我重定向到另一個網頁,仍然有再次驗證彈出。
我將如何再次傳遞用戶名/密碼?
從這樣的回答:
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的一部分,當它終於發佈了。
這看起來像我的Java – Vanatomas
我相信Selenium的Ruby版本可用,並且似乎與最新版本的Selenium(不是Watir)是同步的:https://code.google.com/p/ selenium/wiki/RubyBindings。該代碼將與Java方法類似。 – djangofan