Home | Mirror | Search

6. Browser

6.1. Environment variable

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

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
			

6.3. Open a browser (default: Internet Explorer)

browser = Watir::Browser.new
			

6.4. Watir::Browser.attach

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

6.5. Open Browser at the specified URL

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

6.6. Go to a specified URL

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

6.7. Close the browser

browser.close
			

6.8. 屏幕截圖

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