Skip to content

Supported Selenium 4 features.

aqualityAutomation edited this page Mar 17, 2023 · 12 revisions

One of the main innovations of Selenium 4 is support for the Chrome DevTools Protocol (CDP), which allows to simulate the work of the browser Developer Tools (for example, slowing down the Internet connection, getting logs from the browser console, etc.). These tools can greatly simplify test development and allow you to test previously inaccessible or hard-to-reach functionality of a web application. In Aqality Selenium, Selenium 4 DevTools functionality is implemented in the following classes: DevToolsHandling, EmulationHandling, JavaScriptHandling, NetworkHandling.

CDP Emulation Domain

Geolocation emulation

In Aquality Selenium, arbitrary geolocation is emulated using the following methods:

void setGeolocationOverride(Optional latitude, Optional longitude, Optional accuracy) - sets the current latitude, longitude, and geolocation accuracy. Omitting any of the parameters emulates position unavailable; void setGeolocationOverride(double latitude, double longitude, double accuracy) - has almost the same functionality as the previous method, the only difference is the use of primitives as parameters; void setGeolocationOverride(double latitude, double longitude) - a wrapper over the previous method, setting accuracy = 1. That is 100% geolocation accuracy. void clearGeolocationOverride() - resets the overridden geolocation set by the setGeolocationOverride() method. Geolocation override is demonstrated in the OverrideGeolocationTest class.

In the overrideGeolocationTest test, using the setGeolocationOverride() method, a new geolocation is set (LAT_FOR_OVERRIDE, LNG_FOR_OVERRIDE coordinates) and checks that the coordinates have been changed. Next, the geolocation is reset using the clearGeolocationOverride() method to the default value and it is checked that the coordinate values have returned to their original values.