testerteaser
testerteaser

Reputation: 421

How to Maximize a firefox browser window using Selenium WebDriver with node.js

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

Upvotes: 39

Views: 116412

Answers (13)

Pedro Lobito
Pedro Lobito

Reputation: 98881

As of 2020, the correct answer is :

driver.maximize_window()

Upvotes: 2

Karthic.K
Karthic.K

Reputation: 436

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.

Upvotes: 6

Stackcraft_noob
Stackcraft_noob

Reputation: 241

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);

Upvotes: 1

Ayush
Ayush

Reputation: 949

Try this:

self.ff_driver = Firefox()
self.ff_driver.maximize_window()

Upvotes: 1

Ankur Gupta
Ankur Gupta

Reputation: 301

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

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

Upvotes: 0

Amit Pal
Amit Pal

Reputation: 177

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

Upvotes: 4

Bhupendra Singh
Bhupendra Singh

Reputation: 99

First instantiate a firefox driver

WebDriver driver = new FirefoxDriver();

then maximize it

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

Upvotes: 9

Vil Ignoble
Vil Ignoble

Reputation: 41

driver.Manage().Window.Maximize(); 

Upvotes: 1

user4129706
user4129706

Reputation: 11

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.

Upvotes: 1

niharika_neo
niharika_neo

Reputation: 8531

Have you tried :

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

Doc

Upvotes: 70

user3043660
user3043660

Reputation: 11

Call window as a function.

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

Upvotes: 1

Rony Barua
Rony Barua

Reputation: 103

Try this working for Firefox:

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

Upvotes: 2

einstein
einstein

Reputation: 13850

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

var window = new webdriver.WebDriver.Window(driver);
window.maximize();

Upvotes: 1

Related Questions