简体   繁体   中英

Start firefox browser in maximized form - Selenium Webdriver

I wanted to ask if there is a way in selenium webdriver to initiate the firefox driver in maximized form.

I know driver.manage().window().maximize(); will do the job, but with this the browser is opened in restored form and after couple of seconds it goes to maximized form. What I want is to open the browser in maximized instantly when my test runs. ChromeOptions works for chrome browser like following,

System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--start-maximized");
            driver = new ChromeDriver(options);

Is there a similar way for firefox as well?

I am afraid that you will not find anything better than driver.manage().window().maximize(); .

Look at this workitem. It was raised 10 years ago.

https://bugzilla.mozilla.org/show_bug.cgi?id=873618

open your firefox manually and maximize it.

Close the browser.

open it again, it should open in maximize state, because firefox remembers the last opened state.

Now open the firefox from webdriver code, it should also start in maximize mode.

if the above is not happening, your firefox browser needs to be "refreshed". See this link https://support.mozilla.org/en-US/kb/changes-toolbars-and-window-sizes-are-not-saved

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM