Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

4.6. Browser

4.6.1. Environment variable

> set watir_browser=ie
> set watir_browser=firefox
> set watir_browser=safari
			

4.6.2. Browser options

Watir::Browser.default = 'ie'
Watir::Browser.default = 'firefox'
			

Specifying additional options (IE only)

Speed up execution
(or use the "-b" command line switch)

browser.speed = :fast
Maximize browser window

browser.maximize
Pop browser window to front

browser.bring_to_front
			

4.6.3. Open a browser (default: Internet Explorer)

browser = Watir::Browser.new
			

4.6.4. Watir::Browser.attach

$ firefox -jssh
			
browser = Watir::Browser.attach(:title, 'Mozlla Firefox')
			

4.6.5. Open Browser at the specified URL

browser = Watir::Browser.start("http://google.com")
			

4.6.6. Go to a specified URL

browser.goto("http://amazon.com")
			

4.6.7. Close the browser

browser.close
			

4.6.8. 屏幕截图

browser.driver.save_screenshot 'screenshot.png'
			
comments powered by Disqus