0

I have some scripts which are running on Firefox browser. Here, the problem was, I am using driver.manage().window().maximize(); code to maximize the browser. It is working perfectly fine with Windows 7 environment but, coming to Windows 10 environment, after opening browser, window is set to some small size. Not sure why it is happening!

Please help me on this

NOTE: I am using latest firefox driver(gecko) and latest version of firefox browser.(In both Windows 7 and windows 10)

1
  • I'm using the same - Win 1o and FF - version 56 but haven't faced this issue. Commented Nov 7, 2017 at 3:14

2 Answers 2

0

That's a weird one but try:

((FirefoxDriver)driver).getKeyboard().pressKey(Keys.F11);

Also, I'm assuming this doesn't work:

driver.manage().window().setSize(new Dimension(1024, 768));
0

Not sure why that would happen in Windows 10 (same thing works for me).

Couple of things you could try depending on what you need:

  1. Add width and height options to the Firefox initialisation set to the screen resolution you need it to open as.
  2. Also run it headless with those dimensions set (as do you need to see the browser if it's running in the background?)
System.setProperty("webdriver.gecko.driver", locationFirefoxDriver);
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.addArguments("--width=1920");
firefoxOptions.addArguments("--height=1080");
firefoxOptions.setBinary(firefoxBinary);
driver = new FirefoxDriver(firefoxOptions);

Although I can understand not bothering with Headless and Firefox. With Chrome you get about 30% speed improvement. Firefox, I'm not sure it's even 3%.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.