您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Watir
Watir WebDriver對于用戶驗證的處理
作者:網絡轉載 發(fā)布時間:[ 2014/1/9 10:35:46 ] 推薦標簽:Watir WebDriver

有一些網站,在訪問的時候,會先彈出一個驗證窗口,要求你輸入用戶名和密碼。

一般來說,常見的網站都是采用默認的驗證方式,也是說,你只需要在URL里附帶user/passwod行,例如:

require 'watir-webdriver'
b = Watir::Browser.new :firefox
b.goto 'http://admin:password@192.168.0.1'

但是,有些網站采用更嚴格的驗證方式,比如NTLM,這時候需要驗證的是proxy。

簡單的快速解決方法,是手工的進入該網站一次,這樣驗證方式存在當前的profile里了,對于ff來說,直接使用默認的profile即可:

require 'watir-webdriver'
b = Watir::Browser.new :firefox, :profile => 'default'
b.goto 'http://192.168.0.1'

當然復雜的也不會太復雜,安裝一個addon可以解決:

profile = Selenium::WebDriver::Firefox::Profile.from_name 'WatirWebDriver'
profile.add_extension 'autoauth-2.1-fx+fn.xpi'
b = Watir::Browser.new :firefox, :profile => profile
b.goto 'http://192.168.0.1'


總之,基本策略是:

1. 使用ff的profile manager創(chuàng)建一個profile
2. 把需要的驗證信息,加入profile
3. 在測試中,指定使用這個profile
4. 添加AutoAuth插件,一勞永逸

這個方法 目前也對ff和chrome可用,ie的話,手工配置

軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd