简体   繁体   中英

How to maximize browser (IE) with Watir using Ruby

I am new in Watir as well as Ruby. I have written an automated test for google search using Watir and executed it successfully (my file name is "googlesearch.rb" ). But the browser ( IE ) was opened as small window. How to maximize the browser using Watir?

My watir test script is as below:

require 'watir'
browser = Watir::Browser.new
browser.goto("www.google.com")
browser.text_field(:id, "gbqfq").set("Ripon Al Wasim")
browser.button(:name, "btnG").click
browser.link(:text, "User Ripon Al Wasim - Stack Overflow").click

I executed the test script by using the command: ruby googlesearch.rb

For watir-webdriver : You just need to use the method #maximize .

require 'watir'
require 'watir-webdriver'

browser = Watir::Browser.new
browser.goto("www.google.com")
browser.window.maximize
# ... rest code here goes

Or, if you are using only watir gem to work with IE browser only on Windows . Then you could write it as using maximize .

require 'watir'

browser = Watir::Browser.new
browser.goto("www.google.com")
browser.maximize
# ... rest code here goes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM