Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 知乎專欄 | 視頻教程 | About

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'