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

有一些網(wǎng)站,在訪問的時(shí)候,會(huì)先彈出一個(gè)驗(yàn)證窗口,要求你輸入用戶名和密碼。

一般來說,常見的網(wǎng)站都是采用默認(rèn)的驗(yàn)證方式,也是說,你只需要在URL里附帶user/passwod行,例如:

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

但是,有些網(wǎng)站采用更嚴(yán)格的驗(yàn)證方式,比如NTLM,這時(shí)候需要驗(yàn)證的是proxy。

簡單的快速解決方法,是手工的進(jìn)入該網(wǎng)站一次,這樣驗(yàn)證方式存在當(dāng)前的profile里了,對于ff來說,直接使用默認(rèn)的profile即可:

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

當(dāng)然復(fù)雜的也不會(huì)太復(fù)雜,安裝一個(gè)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)建一個(gè)profile
2. 把需要的驗(yàn)證信息,加入profile
3. 在測試中,指定使用這個(gè)profile
4. 添加AutoAuth插件,一勞永逸

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

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