Create generic methods like: public void zoomIn() { zoomValue += z oomIncrement ; zoom(z oomValue ); } public void zoomOut() { zoomValue -= z oomIncrement ; zoom(z oomValue ); } private static void zoom( int level ) { JavascriptExecutor js = (JavascriptExecutor) driver ; js .executeScript( "document.body.style.zoom='" + level + "%'" ); } And then call ZoomIn() and ZoomOut() wherever you want. Complete sample code: import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; import io.github.bonigarcia.wdm.WebDriverManager; public class zoomTest { public static WebDriver driver ; private int z oomValue = 100; private int z oomIncrement = 20; public void zoomIn() { zoomValue += z oomIncrement ; zoom(z oomValue ); } pu...
A blog about my testing stories where I pen down my thoughts about test automation covering primarily Selenium, Java, Rest Assured, Karate, Maven, TestNG, Postman, newman, Jenkins, Git, Azure DevOps, etc.