Skip to main content

Posts

Showing posts with the label WebDriver

Selenium 4.6.0 released with Selenium Manager

Implementation of Selenium Manager across bindings is one of the key features of the Selenium 4.6.0 release. The Selenium project wants to simplify how we all set up our environment. Setting up browser drivers has been for many years a task that we need to perform all the time.  To run a Selenium test with Selenium 4.6.0, we only need to have Chrome, Firefox, or Edge installed. If you already have browser drivers installed, this feature will be ignored.  Just add 4.6.0 Selenium dependency: <dependency>     <groupId>org.seleniumhq.selenium</groupId>     <artifactId>selenium-java</artifactId>     <version>4.6.0</version> </dependency> And as is use: WebDriver driver = new ChromeDriver(); Also, future releases of Selenium Manager will eventually even download browsers if necessary. :) Enjoyed reading this article? Please share the knowledge with your friends and colleagues.

How to set the browser's zoom level via JavascriptExecutor in Selenium WebDriver (Java)

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...