Reputation: 417
I am currently working in a selenium with java automation proyect. The web page I am automating opens a side menu depending on the size of the screen. In my case, it does not open it. To solve this you can either clic on the menu button to open it or change the zoom. I am trying to implement the second solution zooming (this is the solution I need): JavascriptExecutor jse = (JavascriptExecutor)driver; jse.executeScript("document.body.style.zoom='70%'");
The zoom works but the side menu does not appear. Is there anything extra that I need to do?
I also use the next line as part of my configurations: ChromeOptions options = new ChromeOptions(); options.addArguments("window-size=1980,1080");
I also tried different ways to zoom in but the results are the same:
driver.findElement(By.tagName("html")).sendKeys(Keys.CONTROL,Keys.SUBTRACT);
WebElement html = driver.findElement(By.tagName("html")); new Actions(driver) .sendKeys(html, Keys.CONTROL, Keys.SUBTRACT, Keys.NULL) .perform();
Any suggestions? I would appreciate them because I am new to selenium and I am pretty stuck with this issue.
Upvotes: 1
Views: 49
Reputation: 417
driver = new ChromeDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
driver.get("chrome://settings/");
jse.executeScript("chrome.settingsPrivate.setDefaultZoom(0.9);");
driver.get("...");
This is how I managed myself to do zoom correctly.
Upvotes: 0