Selenium 4 is now W3C compliant; what does it mean for you?

Selenium 4 is now W3C compliant; what does it mean for you?

Posted by admin| Posted On January 7th, 2021|General

Selenium 4 is now W3C compliant; what does it mean for you?
 
 
 
 
 
 

What is Selenium WebDriver

  • Selenium WebDriver drives a browser natively, as a real user would, either locally or on remote machines.
  • Works in all major browsers.
  • With Selenium 4, the WebDriver is now W3C compliant.
  • Selenium automates browsers. That’s it! What you do with that power is entirely up to you.

Introduction to Selenium 4

With Selenium 4, the WebDriver fully adopted the W3C WebDriver protocol and has dropped support for the original home-grown JSON wire protocol. Browsers like Chrome, Safari, Firefox, Internet Explorer and Edge will also follow W3C standardization. Therefore, browser drivers will interact with Selenium WebDriver in W3C standard protocol. The capabilities format will change in the new standard.

 

JSON Wire Protocol – the existing protocol

Selenium communicates with a web browser via a wire protocol that’s effectively just JSON over HTTP. Originally this grew organically as the Selenium team figured things out and tried to make browsers do what is needed. That original protocol is known as the JSON wire protocol because it spoke JSON over the wire.

So, the Protocol Web Driver has been running for a long time is JSON Wire Protocol. However, starting with Selenium 4, this protocol will no longer be supported.

WebDriver W3C Protocol – the new protocol

That original protocol was the base for the W3C WebDriver protocol, which smoothed some of the rough edges, and brought much-needed consistency to the protocol. The two major areas the standardized protocol improved on included session creation, removing considerable ambiguity and providing a far richer API for specifying user actions. The most important difference in the actions API is that you can do multiple actions simultaneously.

The new protocol is called: “WebDriver W3C”. It has received the endorsement of the “World Wide Web Consortium” (W3C). This is an international community that works to develop Web standards. The creation of this protocol started 6 years ago, and just one year ago, it finally became a standard. W3C is fractionally different from the original protocol.

What does this adoption of the W3C protocol mean for you?

To be honest, it probably doesn’t mean much to you at all. If you’re using a modern browser (released over the past couple of years), you will find that you already speak the W3C protocol with Selenium 3.

 

Then, who does care about the protocol? – Cloud Platforms!

When we talk about companies like SauceLabs, BrowserStack, and LambdaTest, who provide Selenium as a service—they care about it. The ecosystem is ready for this next step because the technical folks at these companies have ensured that they understand and comply with the W3C protocol. Folks from the Selenium project have offered help and advice as needed.

 

What does it mean to the existing Selenium Automation Projects?

One of the other nice things about Selenium 4 is that it has a stable user-facing API. That means upgrading your project from Selenium 3 to Selenium 4 should be a drop-in upgrade. You just change the version number, recompile, and you should be done.

 

Mobile Automation

It is important to point out that WebDriver API has grown to be useful even outside of Selenium. For example, Appium is a test automation framework that leverages the WebDriver protocol. It supports app automation across various mobile platforms, such as iOS, Android, and Windows. Appium also has added full W3C specification support, starting with version 1.9.

Major Advantages of the WebDriver W3C Protocol

  • The automated Selenium testing will run more consistently across browsers as the browsers, and Selenium WebDriver use the same protocol.
  • With WebDriver W3C Protocol, automated Selenium testing will be less flaky and more stable. Stability in tests is a major reason to shift to Selenium 4.
  • Actions API in WebDriver W3C Protocol are richer than those in JSON Wire Protocol. The Actions API is revamped to conform with the WebDriver Spec. Action APIs would now let you perform multi-touch actions, zoom-in, zoom-out, pressing two keys simultaneously, and more.
    For example, the Pinch-zoom sequence in W3C Protocol is represented by an action sequence consisting of three ticks and two-pointer devices of type-touch.
  • Standardization of W3C opens up opportunities for promoting compatibility beyond WebDriver API implementations.
  • Websites with W3C compliance help reduce maintenance efforts, as cleaner code results in improved readability.

Conclusion

Summing up, implementing the W3C protocol should not generate major problems. On the contrary, the new protocol is expected to obtain great benefits regarding the consistency and stability of the tests in different browsers. Furthermore, the WebDriver API will be updated, adding modern actions. 

Upgrading to Selenium 4 should be painless if you use one of the officially supported languages (Ruby, JavaScript, C#, Python, and Java). There might be some cases where a few issues can happen, and this guide will help you to sort them out. We will go through the steps to upgrade your project dependencies and understand the major deprecations and changes the version upgrade brings.

Guide to upgrade to Selenium 4

Please feel free to reach out to us at sales@qualitlabs.com for any help.

Comments are closed.