Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a browser in fullscreen mode using watir-webdriver

I know this is a very silly question. Yet, am not able to find how to make the browser open in fullscreen mode using watir webdriver. i tried using maximize() but in vain. This is how the code looks like:

require "rubygems"
require "watir-webdriver"
ff = Watir::Browser.new(:firefox)
ff.goto("http://google.com")
ff.maximize()

getting the error "undefined method maximize"

like image 974
Chandiran Avatar asked Jul 14 '11 09:07

Chandiran


People also ask

What is Watir Selenium?

Watir is an open-source web application testing framework that is designed to make writing Selenium tests simple and efficient. Built on Selenium's Ruby language bindings, Watir is able to drive the browser in the same way humans do.

What is Watir used for?

Definition: Watir, pronounced as water, is a group of Ruby libraries for automated web browsers. It allows writing the tests which are easy to read and maintain. In other words, it is a simple and flexible tool. Description: Watir drives the browsers the same way as people do.

What is Watir WebDriver gem?

Watir-WebDriver (Watir is short for Web Application Testing in Ruby) is a Ruby gem which allows you to automate your browser (make it click a button, submit a form, wait for some text to appear before continuing, and so on).


2 Answers

Right now, it's possible to maximize the browser doing:

require "rubygems"
require "watir-webdriver"
browser = Watir::Browser.new(:firefox)
browser.goto("http://google.com")    
browser.driver.manage.window.maximize

Actually is going down to Selenium Driver to handle it, and AFAIK it works fine in Firefox and Chrome.

like image 113
Gonzalo Avatar answered Oct 03 '22 23:10

Gonzalo


what worked for me is the following

in hooks.rb (if you are using cucumber)

Before do
    @browser = Watir::Browser.new :firefox #( :chrome, :ie, etc)
    @browser.driver.manage.window.maximize
end
like image 44
trickymuffin Avatar answered Oct 03 '22 23:10

trickymuffin