Selenium 4.0(alpha) – What Test Automation Engineers can expect!
Selenium team has added Selenium 4.0 Alpha to mvnrepository two weeks back(24th April) and has created a buzz in the Automation QA Community.
The QA fraternity has been eagerly waiting for one or more features proposed in this release. The most significant of them would be the W3C Standardization. It would make the Framework much more stable and reduce some of the compatibility issues across different Web Browsers.
Another beginner-friendly change that is coming with this major release is updated Documentation. After version 2, Selenium Documentation had not been thoroughly updated. The updated documentation would help beginners, as well as the experienced, immensely.
We also hope some of the drawbacks in the article Pros and Cons of Selenium as an Automation Testing tool will be handled by Selenium 4.
Let us look at some of the prominent changes that we can expect in Selenium 4. And if you dig in at the right place, you can see the complete list of changes in CHANGELOG or CHANGES file – Selenium Github Repo
Note: This is not a complete list and I have deliberately omitted many of the underlying implementation and architectural changes that a regular QA Automation guy like me wouldn’t have to deal with on a daily basis 😀
Table Of Contents
- 1 Architectural Changes
- 2 API changes
- 3 Standardized Documentation
- 4 Footnote
1. Now using W3C Protocol for Browser-driver Communications
The earlier versions of Selenium used JSON wire protocol which required encoding and decoding of the API. Whereas, Selenium 4 will now use a standard W3C Protocol to communicate between the driver and the browser. The advantage is that W3C protocol doesn’t require encoding or decoding the API and the tests will be able to directly communicate with the Browser.
2. Compliant with W3C WebDriver Specifications
Selenium 4 will be entirely compliant with W3C WebDriver standards and this will include the documentation as well. So, the updated documentation will cover detailed instructions for usage.
Also, The actions API has been revamped to conform with the WebDriver Spec.
3. Removed support for few Browsers
The team will remove native support for Opera and PhantomJS going forward. Still, the users who need to test Opera can rely on Chrome since Opera is based on Chromium(which Chrome is forked from) and for PhantomJS users can use Chrome or Firefox in headless mode.
Selenium Server now no longer includes HtmlUnit by default.
4. Optimized Selenium grid
Alpha version of new Grid Server supports “standalone”, “hub”,
“node”, and completely distributed usage. Also, this new Grid Server can output logs in single-line JSON format to the stdout.
5. Added limited support for Opentracing and Docker
Basic support for OpenTracing landed. Use the –ext flag to the new Grid Server to provide the classpath to an OpenTracing implementation.
Selenium 4 will introduce Basic support for using Docker containers with the new Grid Server. More information will be available once the official documentation is released.
Check out Testsigma to see how most of these things are already considered and made available to all our customers.
1. Changes to Window class
- All window manipulation commands are now supported – fullscreen() and minimize() methods will be added.
- Added getRect() & setRect() and removed getSize() & getPosition() – The getRect() method retrieves a rect describing the current top-level window’s size and position. setRect() method sets the current top-level window’s size and position. This will replace the getSize() and getPosition() methods – Underlying implementation methods (These changes are not relevant in common usage).
2. Changes to Builder class
- Added “setChromeService”, “setEdgeService”, & “setFirefoxService” methods – Underlying implementation methods (These changes are not relevant in common usage).
3. Changes to chrome.Driver
- Added sendDevToolsCommand() – The sendDevToolsCommand() method sends an arbitrary devtools command to the browser and returns a promise that will be resolved when the command has finished.
- Added setDownloadPath() – The setDownloadPath() method sends a DevTools command to change Chrome’s download directory and returns a promise that will be resolved when the command has finished.
4. Changes to firefox.Driver
- Added installAddon(path) – The installAddon() method installs a new addon within the current session. This function will return an “id” that can be used to uninstall the addon using uninstallAddon().
- Added uninstallAddon(id) – Uninstall the Addon using ID.
- Added addExtensions() – Add extension to the automation session easily.
- Added setPreference() – Add preferences to the session.
5. Changes to Options Class
- Options class now extends Capabilities class for Chrome, Firefox, IE, Safari.
- Removed the firefox.profile class. All of its functionality is now provided directly by firefox.options.
- setProfile now only accepts a path to an existing profile.
6. Changes to Errors
- Added ElementClickInterceptedError – The Selenium code throws ElementClickInterceptedError when a click command cannot complete due to the click target being obscured by other elements on the page.
- Added InsecureCertificateError – The Selenium code throws InsecureCertificateError when a navigation event causes the browser to generate a certificate warning. An expired or invalid TLS certificate usually cause this.
- Added InvalidCoordinatesError – The Selenium code throws InvalidCoordinatesError when an interaction operation becomes invalid due to the passing of invalid coordinates.
- Added NoSuchCookieError – The Selenium code throws NoSuchCookieError when a named Cookie is missing in the cookie jar for the current document.
- Removed ElementNotVisibleError
- Removed InvalidElementCoordinatesError
7. Changes to WebDriver
- Added driver.switchTo().parentFrame() – We can use it to go from the child frame to the parent frame directly.
- Removed touchActions
8. Changes to Alerts
- Removed authenticateAs
- Element screenshots are now possible
- Added support for WebSockets to the HttpClient
- Deleted many of the deprecated methods and classes
The main problem which most Selenium users face is that there is no proper and updated documentation for Selenium. The Selenium team has not updated the documentation since Selenium 2.0. With Selenium 4, they have updated Selenium’s official documentation to explain the latest changes.
While it’s great to see the improvements that are expected to be covered in Selenium 4, it would be a hassle for small and medium-sized teams to read through the API docs, analyze the changes, and rectify the tests broken by the updates due to the considerable changes.
Many of the above-discussed changes have already been implemented by test automation tools like Testsigma.
With a cloud-based tool like Testsigma, the updates will be reviewed internally and applied to all the customer’s tests automatically without any additional time, resources and efforts from the teams and is very easy for functional teams to get started!