Ripon Al Wasim
Ripon Al Wasim

Reputation: 37756

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

Upvotes: 0

Views: 1058

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118271

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

Upvotes: 4

Related Questions