-1

I am automating a web application in ME-Edge in IE Mode on Windows 11. I have to set zoom level to 80% for same requirement for all end to end test cases. I tried with multiple given code // To zoom out 3 times

for(int i=0; i<3; i++){
driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL,Keys.SUBTRACT));
}

Also tried with JavascriptExecutor, but its working for launching page, once logged in and it goes to next page where browser zoom will be 100% again and execution stops.

 JavascriptExecutor jse = (JavascriptExecutor)driver;
       Thread.sleep(3000);
       System.out.println("Zoom with 80%");
              jse.executeScript("document.body.style.zoom='80%'");

Also, tried with press CTRL+SUBTRACT but script stops further execution.

System.setProperty("webdriver.ie.driver",
                    FileReaderManager.getInstance().getConfigReader().getDriverPath()
                            + "\\IEDriverServer32bit.exe");
            InternetExplorerOptions edgeIe11Options = new InternetExplorerOptions();
            Map<String, Object> ops = (Map<String, Object>) edgeIe11Options.getCapability("se:ieOptions");
            ops.put("ie.edgechromium", true);
            ops.put("ie.edgepath", "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");                edgeIe11Options.introduceFlakinessByIgnoringSecurityDomains();
            edgeIe11Options.ignoreZoomSettings();
            edgeIe11Options.enablePersistentHovering();
            edgeIe11Options.getBrowserName();
            edgeIe11Options.takeFullPageScreenshot();
            // edgeIe11Options.disableNativeEvents();
            edgeIe11Options.requireWindowFocus();
            edgeIe11Options.destructivelyEnsureCleanSession();
            edgeIe11Options.setCapability("ignoreProtectedModeSettings", true);
            edgeIe11Options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
            
            driver = new InternetExplorerDriver(edgeIe11Options);
Prashant
  • 1,351
  • 3
  • 20
  • 32
  • @KendrickLi, I have not found any solution as of now. I tried your solution too but it didnt work out for me. – Prashant Nov 02 '22 at 09:49
  • Hi @Prashant , after some investigation, I haven't found any possible solution yet. So, I think it is necessary to avoid a different zoom level in IE mode automation. – Kendrick Li Nov 11 '22 at 07:54

1 Answers1

0

You have almost every possible means of setting the zoom level, but it usually will not cause any issue except when you perform some mouse action. Notes from Selenium docs:

The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

So I would suggest restoring the browser zoom level to 100% when you need to perform mouse action, and zoom in/out when you actually need it, though it may sound rather complicated.

Kendrick Li
  • 1,355
  • 1
  • 2
  • 10