[firefox] 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

This question is related to firefox selenium-webdriver

The answer is


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.


First instantiate a firefox driver

WebDriver driver = new FirefoxDriver();

then maximize it

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

Call window as a function.

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


Try this:

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

Try this working for Firefox:

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

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

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

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


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

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

Have you tried :

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

Doc


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.


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

As of 2020, the correct answer is :

driver.maximize_window()


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

Examples related to firefox

Drag and drop menuitems Class has been compiled by a more recent version of the Java Environment Only on Firefox "Loading failed for the <script> with source" Selenium using Python - Geckodriver executable needs to be in PATH Selenium using Java - The path to the driver executable must be set by the webdriver.gecko.driver system property How to use the gecko executable with Selenium Selenium 2.53 not working on Firefox 47 Postman addon's like in firefox Edit and replay XHR chrome/firefox etc? How to enable CORS on Firefox?

Examples related to selenium-webdriver

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81 Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser How to configure ChromeDriver to initiate Chrome browser in Headless mode through Selenium? How to make Firefox headless programmatically in Selenium with Python? Selenium Web Driver & Java. Element is not clickable at point (x, y). Other element would receive the click How do you fix the "element not interactable" exception? Scrolling to element using webdriver? Only local connections are allowed Chrome and Selenium webdriver Check if element is clickable in Selenium Java