I have a requirement, where I need to perform Zoom In and Zoom out using selenium webdriver. So this is the short cut key that i need to perform. Control+Shift+Add
Key.
I tried the below code in chrome browser. But unable to perform action. Could anyone have the right solution?
Actions actions = new Actions(driver);
actions.keyDown(Keys.CONTROL).keyDown(Keys.SHIFT).sendKeys(Keys.chord(Keys.ADD)).keyUp(Keys.CONTROL).keyUp(Keys.SHIFT).perform();
Chrome Version - 62
Selenium Version - 2.53
OS - Windows 7 and 10
If you are using headless chrome, you can add --force-device-scale-factor=1.5
argument to change the zoom level
If you want to do the zoom in chrome (not with the css) you can use the API. For example:
driver.get('chrome://settings/')
driver.execute_script('chrome.settingsPrivate.setDefaultZoom(1.5);')
driver.get("https://www.google.co.uk/")
EDIT
In Java:
System.setProperty("webdriver.chrome.driver", /pathTo/chromeDriver);
ChromeDriver driver = new ChromeDriver();
driver.get("chrome://settings/");
driver.executeScript("chrome.settingsPrivate.setDefaultZoom(1.5);");
driver.get("https://www.google.co.uk/");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With