I have a need programatically zoom the browser to 90%. It is because of a certain bug in the application code which should be fixed in time but might take a long time. I have tired at least three methods as follows to do the zooming but none actually do anything for me except for the js method which I've been able to get to work only in Chrome. I'm also aware of statements I found in my searches indicating that Selenium assumes a 100% zoom level and that it might have trouble finding elements if the zoom is changed. Chrome seems to fit this since when I zoom it to 90% it has trouble finding some elements. I have found FF to be somewhat more robust after it is zoomed to 90%, but I have not been able to get any of the following methods to do anything to FF/Gecko programatically. I've read a number of posts. Most of them cover these methods and a few more. I've not been able to get any of the to work for FF. I wonder if there is something I'm missing or if the selenium browser drivers just don't allow it anymore. Sure would appreciate any help Thx :)
actions.keyDown(Keys.CONTROL).keyDown(Keys.SHIFT).sendKeys(Keys.chord(Keys.ADD)).keyUp(Keys.CONTROL).keyUp(Keys.SHIFT).perform();
WebElement html = driver.findElement(By.xpath("//html"));
new Actions(driver).sendKeys(html, Keys.CONTROL, Keys.ADD, Keys.NULL) .perform();
wait.until(elementToBeClickable(By.tagName("html"))).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT));
Robot robot = new Robot(); |
for (int i = 0; i < 3; i++) { |
robot.keyPress(KeyEvent.VK_CONTROL); |
robot.keyPress(KeyEvent.VK_ADD); |
robot.keyRelease(KeyEvent.VK_ADD); |
robot
.keyRelease(
KeyEvent.VK_CONTROL);
}
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.body.style.zoom = '.9'");