38

How do we maximize a firefox browser using Selenium WebDriver (Selenium 2) with node.js. I am using wd package for Selenium WebDriver to write the tests. I have tried executing window.resizeTo(1366,768); usin eval or execute but didn't work.

I am using Selenium WebDriver 2.25.0

Robin Daugherty
  • 7,115
  • 4
  • 45
  • 59
testerteaser
  • 411
  • 1
  • 5
  • 7

13 Answers13

69

Have you tried :

driver.manage().window().maximize() 

Doc

Ajinkya
  • 22,324
  • 33
  • 110
  • 161
niharika_neo
  • 8,441
  • 1
  • 19
  • 31
  • 1
    I'm using asynchronous style programming with node.js. I've tried to use it after the driver.init() call but it returns "TypeError: Object # has no method 'manage'" – testerteaser Dec 27 '12 at 12:52
  • 4
    If you're using capybara: `page.driver.browser.manage.window.maximize` (ie access selenium driver via `page.driver.browser`). – Zubin May 22 '13 at 00:36
9

First instantiate a firefox driver

WebDriver driver = new FirefoxDriver();

then maximize it

 driver.manage().window().maximize();
John Demetriou
  • 4,093
  • 6
  • 52
  • 88
5

Use this code:

driver.manage().window().maximize() 

works well,

Please make sure that you give enough time for the window to load before you declare this statement.

If you are finding any element to input some data then provide reasonable delay between this and the input statement.

iamsankalp89
  • 4,607
  • 2
  • 15
  • 36
Karthic.K
  • 416
  • 5
  • 15
4
driver.manage().window().maximize();
Horizon_Net
  • 5,959
  • 4
  • 31
  • 34
Amit Pal
  • 177
  • 3
  • 11
2

Try this working for Firefox:

driver.manage().window.maximize();
Tasawer Khan
  • 5,994
  • 7
  • 46
  • 69
Rony Barua
  • 93
  • 1
  • 5
1

If you are using Selenium WebdriverJS than the below code should work:

var window = new webdriver.WebDriver.Window(driver);
window.maximize();
einstein
  • 13,389
  • 27
  • 80
  • 110
1

Call window as a function.

driver.manage().window().maximize();

CDub
  • 13,146
  • 4
  • 51
  • 68
1

The statement :: driver.manage().window.maximize(); Works perfectly, but the window maximizes only after loading the page on browser, it does not maximizes at the time of initializing the browser.

here : (driver) is called object of Firefox driver, it may be any thing depending on the initializing of Firefox object by you only.

Volker E.
  • 5,911
  • 11
  • 47
  • 64
1
driver.Manage().Window.Maximize(); 
Undo
  • 25,519
  • 37
  • 106
  • 129
Vil Ignoble
  • 41
  • 1
  • 2
  • 10
1

Try this:

self.ff_driver = Firefox()
self.ff_driver.maximize_window()
Ayush
  • 909
  • 1
  • 13
  • 32
1

One way, everyone already have written in thier answers:

driver.manage().window().maximize() 

but if you looking for alternative ways, here you are:

driver.manage().window().setSize(screenResolution);

or

driver.findElement(By.id("......")).sendKeys(Keys.F11);
Stackcraft_noob
  • 231
  • 2
  • 4
0
driver.manage().window().maximize() ;

works perfectly and at the very beginning it maximizes the window. Does not wait to load any page.

Ankur Gupta
  • 301
  • 4
  • 12
0

As of 2020, the correct answer is :

driver.maximize_window()

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268