Opening a browser in full screen using watir-webdriver

I know this is a very stupid question. However, I cannot find how to make the browser open in full screen using watir webdriver. I tried using maximize (), but in vain. This is what 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"

+8
ruby watir-webdriver watir
source share
7 answers

If you know the screen size, you can move the browser to the upper left corner and set its size to the screen size: Set the browser window size in Watir-webdriver .

+3
source share

It is currently possible to maximize the browser:

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

It actually goes to the Selenium Driver to process it, and AFAIK works fine in Firefox and Chrome.

+5
source share

I am using ruby ​​+ watir-webdriver and this code works for both Firefox browsers and IE (I have not tested in other browsers)

 screen_width = browser.execute_script("return screen.width;") screen_height = browser.execute_script("return screen.height;") browser.driver.manage.window.resize_to(screen_width,screen_height) browser.driver.manage.window.move_to(0,0) 
+4
source share

the following worked for me

in hooks.rb (if you use a cucumber)

 Before do @browser = Watir::Browser.new :firefox #( :chrome, :ie, etc) @browser.driver.manage.window.maximize end 
+3
source share

It worked for me! You should say .window.maximize instead of .maximize

 browser = Watir::Browser.new "firefox" browser.goto "http://example.com" browser.window.maximize 
+3
source share

I'm not sure about the ruby ​​or watir code, but for Chromedriver in selenium you cannot just call a window to maximize with driver.manage (). window (). maximize ();

Instead, you need to do some neat little work. You need to pass the Chromedriver option. See this post. How do I set Chrome preferences using the Selenium Webdriver.NET binding?

 var options = new ChromeOptions(); options.AddArgument("-start-maximized"); //start the chromedriver IWebDriver driver = new ChromeDriver(@"*Path_To_Chromedriver*", options) //Perform your test driver.Quit(); 
0
source share

It worked for me

 @browser = Watir::Browser.new @browser.goto("http://google.com") @browser.driver.manage().window().maximize 
-one
source share

All Articles