Watir-webdriver_Firefox

本文介绍如何使用Watir-WebDriver与Firefox浏览器进行集成测试,包括设置Firefox配置文件、指定代理、使用Firebug等常见操作。
It just works™
Firefox is supported through a JavaScript driver, therefore ‘it just works™’ on all platforms.
b = Watir::Browser.new :firefox
Firefox Profiles
By default, the Firefox driver creates a new Firefox profile for each test run, which is the recommended action.
You can specify an existing profile to use, such as your ‘default’ profile:
b = Watir::Browser.new :firefox, :profile => 'default'
You can also create a new Firefox profile each test run using any of the options that you can configure in the about:config pane of Firefox
For example:
profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.dir'] = "/tmp/webdriver-downloads"
profile['browser.download.folderList'] = 2
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf"
b = Watir::Browser.new :firefox, :profile => profile
Native Events on Microsoft Windows
Native events are enabled on Windows by default and intend to provide a lower level interaction between webdriver and the operating system. However, these seem to cause problems in certain conditions. These can be easily disabled by setting the option on the Firefox profile:
profile = Selenium::WebDriver::Firefox::Profile.new
profile.native_events = false
Watir::Browser.new :firefox, :profile => profile
Specifying a proxy to use with Firefox
profile = Selenium::WebDriver::Firefox::Profile.new
profile.proxy = Selenium::WebDriver::Proxy.new :http => 'myproxy.com:8080:, :ssl => 'myproxy.com:8080'
b = Watir::Browser.new :firefox, :profile => profile
Using Firebug with Watir-WebDriver
First download the Firebug xpi file, then use the following code:
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension "../path/to/firebug.xpi"

b = Watir::Browser.new :firefox, :profile => profile

转载自: http://watirwebdriver.com/firefox/

API:http://rubydoc.info/gems/watir-webdriver/frames

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值