Showing posts with label Selenium Zoom In. Show all posts
Showing posts with label Selenium Zoom In. Show all posts

Monday, February 20, 2023

How to Zoom In, Zoom Out the Chrome, Edge, Safari and Firefox Browsers

 How to Zoom In, Zoom Out the Chrome, Edge, Safari and Firefox Browsers -


We can zoom in, and zoom out the browsers by using the following commands -

"document.body.style.zoom = 'number of % to zoom'";

document.body.style.MozTransform = 'scale(number of % to zoom)';";


public class Tests{

public static void main(String[] args){

WebDriver driver=new ChromeDriver();

driver.get("https://software-testing-made-lifeeasy.blogspot.com/");

JavascriptExecutor js = (JavascriptExecutor)driver;

//The below line will work for these browsers - Chrome, Edge and Safari

String zoomProperty = "document.body.style.zoom = '200.0%'";

//The below line will work only for the Firefox browser

String zoomProperty = "document.body.style.MozTransform = 'scale(0.5)';"; //50% zoom, If you provide scale as 1, it's 100% zoom.

js.executeScript(zoomProperty);

}

}