Today I will tell you what is new and better in Selenium 4.0. Finally, the stable release of Selenium 4 was announced on October 13. So Selenium 4.0 what is new, better?
There are number of things I need to say before explaining the innovations step by step. Firstly, JSON Wire Protocol was the main mode of communication between test code and browser before the new version. The new version uses the WebDriver W3C(World Wide Web Consortium) protocol as it has W3C compatibility. This means the WebDriver will now interact directly with the target browser. This will allow us to cross browser tests healthier. Let me briefly explain the innovations.
Revamped Selenium Grid
Selenium 4 has come up with a new architecture to eliminate previous problems during installation and configuration, as well as problems during the connection between hub and node machine. The new Selenium Grid comes with Docker support and allows testers and developers to spin containers instead of installing heavy virtual machines. Besides, redesigned to allow QAs to deploy the grid in Kubernetes for better scaling. The development of Selenium Grid will improve the DevOps process as it provides compatibility with tools like AWS, Azure.
Improved Selenium IDE
Relative locators, also referred to as Friendly locators and this functionality is added to find element near another web element or we can find web elements by GUI location. We can list the newly added locators, toLeftOf(), toRightOf(), below(), near(), above().
Supporting Chrome Debugging Protocol(CDP)
Selenium 4 provides native support for the Chrome DevTools Protocol (CDP) via the DevTools interface. This ensures QAs can now use Chrome development features like Fetch, Network, Profiler, Performance, App cache and more. Moreover, this feature helps developers and QA’s test and resolve critical bugs for specific web pages more instantly.
Allows the control of new windows
With the new Selenium version, user can open a URL in a new tab with the current tab. I mean this feature allows the user to open multiple windows and manage tabs. You can follow the steps below to open a new window;
Selenium documentation had not been updated since Selenium 2.0. Old Selenium users were experiencing a lot of difficulties due to lack of documentation capability. They have updated all official documentation for Selenium which includes web driver, Grid and IDE to explain the latest changes. The comprehensive documentation covers information about all the tools and API’s under the Selenium umbrella. This will help testers learn about all the features needed to get started with selenium testing.
I have told about the innovations and improvements in Selenium so far, in the next section I will explain the deprecated and the changes.
Deprecation of Desired Capabilities
Desired Capabilities were primarily used in test scripts to define the test environment (browser name, version, Operation Systems) to run on Selenium Grid. This has now been replaced by options. It means testers now need to create an Options object, set test requirements, and pass the object to the Driver constructor. The Options objects included in selenium can be listed as; Firefox – FirefoxOptions, Chrome – ChromeOptions, Internet Explorer (IE) – InternetExplorerOptions, Microsoft Edge – EdgeOptions, Safari – SafariOptions.
Replacements in action class
The Actions class in Selenium is primarily used to simulate mouse and keyboard input actions on certain web elements (Example: Left click, Right click, Double click, etc.). We can list the changes in Action Class in Selenium 4.0 as follows; click(WebElement), contextClick(WebElement), clickAndHold(WebElement), doubleClick(WebElement), release().
Apart from the items I wrote above, there are other features and removed ones. Let me explain them. While previously we were able to take a screenshot of the whole page, we can now take a screenshot of a specific object. Moreover, users can achieve the coordinates, dimension, height, width, etc. as the location of the web elements or object.
These were the innovations of Selenium 4.0. Considering the above, I can see that the features in Selenium 4 are quite promising in terms of facilitating the testing process. I hope I was able to introduce you to Selenium 4.0 a little bit and this information will help to you.