Skip to main content

WebDriver BiDi offers the best of both worlds in browser automation tools

Anyone testing web applications ought to be aware of a new browser automation protocol called WebDriver BiDi. This new protocol is an evolution of the original WebDriver standard and it incorporates some of the benefits of various other automation tools, most notably, adding bidirectional communication. 

“It’s a brand new protocol, and it’s taking all the best ideas that have been out there for a while and trying to standardize it through the W3C,” said David Burns, head of open source at BrowserStack (a browser testing company who is on the WebDriver BiDi working group) and chair of the Browser Testing and Tools Working Group at W3C, which is the group responsible for the WebDriver and WebDriver BiDi specifications. 

The original WebDriver protocol, or WebDriver Classic, is a “remote control interface that enables introspection and control of user agents,” according to its W3C definition. Essentially, it provides a way to remotely control the behavior of web browsers so that applications can be tested in them. 

However, this protocol only offers one-way communication, meaning that the client sends a request to the server, and the server can reply only to that one request, explained Puja Jagani, team lead at BrowserStack and a key code committer for the WebDriver BiDi project.

“The server cannot initiate communication with the client but can only respond. So if something of interest happens in the browsers it cannot communicate back to the client unless the client asks for it,” explained Jagani.

The BiDi in WebDriver BiDi stands for bidirectional communication, meaning that it actually allows events in the browser to stream back to the controlling software.

According to Jagani, because browsers are event-driven, it’s helpful for the browser to be able to share events back to the client when something interesting happens. 

For instance, with this new protocol, users can subscribe to the events created when a network request is sent to or from the browser, which enables them to monitor (or modify) all outgoing requests and incoming responses.

An example of this in action involves an application that is pointing to a production database in the cloud. When testing that application, WebDriver BiDi could be used to modify outgoing requests to point to a test database so that the production database isn’t flooded with test data.

“This is only possible with bidirectional communication. It is not possible without the W3C BiDi protocol,” said Jagani.

CDP vs WebDriver

The Chrome DevTools Protocol (CDP) and WebDriver Classic have historically been often compared because they are both low-level tools — tools that execute remote commands outside of the browser, such as opening multiple tabs or simulating device mode, Jecelyn Yeen, senior developer relations engineer for Chrome, and Maksim Sadym, software engineer at Google, explained in a blog post

High-level tools, by contrast, are those that execute commands within the browser. Examples of these include Puppeteer, Cypress, and TestCafe.

CDP does enable bidirectional communication, but it’s limited for testing purposes because it only works for Chromium-based browsers, like Google Chrome, and wouldn’t work in Firefox or Safari. According to Yeen and Sadym, “WebDriver BiDi aims to combine the best aspects of WebDriver ‘Classic’ and CDP.”

However, BrowserStack’s Burns emphasized that this new protocol isn’t intended to replace CDP, but rather it’s a new testing and automation protocol entirely. “CDP is always going to be there on Chromium browsers,” he said.

It already has browser support 

CDP’s creator, Google, is heavily involved in developing and supporting WebDriver BiDi, as is Mozilla. “We are glad that Mozilla and Google have come and helped us get it to that point where it’s standardized and now everyone can benefit from it,” Burns said. He added that Apple isn’t quite there yet, and it’s not clear at the moment when support for WebDriver BiDi will be available in WebKit-based browsers. 

“Sometimes standards can move at a glacial pace, and part of that is for good reason. It involves creating the collaboration points and getting consensus — and sometimes consensus can be really hard, especially where Google, Mozilla, and Apple, they have their own ideas of what makes something better, and so getting that can be really, really slow to implement,” Burns explained. 

Testing automation tools and testing companies have also started supporting it

In addition to the browsers needing to support it, another piece of the puzzle is getting the testing automation tools and testing providers on board. Fortunately, the automation tools Selenium and WebDriverIO, as well as the testing companies BrowserStack, SauceLabs, and LambdaTest, are all part of the WebDriver BiDi Working Group. 

WebdriverIO and Selenium already have some support for the new protocol, and BrowserStack supports it too. Selenium itself is also updating its entire implementation from WebDriver to WebDriver BiDi. Burns explained that retrofitting the classic version of WebDriver to BiDi is the last major piece of the process, and is expected to be complete within the next year. 

“It’s a volunteer-driven project, so this happens when everyone’s bandwidth and time matches, so it gets done in like spurts or chugs of work, right? But I think that’s how it is for open source development in general,” said Jagani, who is also a member of the Selenium Technical Leadership Committee.

She noted that by Selenium 5 (the current version is 4.24), the goal is to have at least the high-level APIs done, which cover a number of use cases, like giving the user the ability to listen to console logs and the ability to do basic authentication for their website, to name a couple.

Once Selenium 5 is out, the next goal will be to start transitioning commands one by one from WebDriver Classic to WebDriver BiDi. “Hopefully, by Selenium 6, we are BiDi only,” she said. She did go on to explain that it’s a long process with many external variables. Browsers are still in the process of implementing it, and once BiDi is in the stable version of the browser, that’s when Selenium comes in and can start implementing it. After that, there’s still a period where users will need to use it and give feedback so that Selenium can ensure its implementation is resilient.

Jagani said that the user experience should remain the same once Selenium is switched over to BiDi, and there won’t be a big breaking change. 

“That’s what Selenium tries to do — even from Selenium 3 to 4 — we try to make sure it’s a seamless integration with minimal breaking changes,” she said. “Selenium is very big on backwards compatibility as much as possible, or at least ensuring that we’re deprecating things as required so you know we are going to be removing it and giving sufficient warnings. That experience for users using WebDriver Classic would remain the same, because eventually it’ll be the same APIs, just using BiDi under the hood.”

To take advantage of the new advanced capabilities that BiDi brings, there will be newer APIs available, which will be similar to the ones users are already familiar with. 

The post WebDriver BiDi offers the best of both worlds in browser automation tools appeared first on SD Times.



from SD Times https://ift.tt/2BOc1jU

Comments

Popular posts from this blog

Difference between Web Designer and Web Developer Neeraj Mishra The Crazy Programmer

Have you ever wondered about the distinctions between web developers’ and web designers’ duties and obligations? You’re not alone! Many people have trouble distinguishing between these two. Although they collaborate to publish new websites on the internet, web developers and web designers play very different roles. To put these job possibilities into perspective, consider the construction of a house. To create a vision for the house, including the visual components, the space planning and layout, the materials, and the overall appearance and sense of the space, you need an architect. That said, to translate an idea into a building, you need construction professionals to take those architectural drawings and put them into practice. Image Source In a similar vein, web development and design work together to create websites. Let’s examine the major responsibilities and distinctions between web developers and web designers. Let’s get going, shall we? What Does a Web Designer Do?

A guide to data integration tools

CData Software is a leader in data access and connectivity solutions. It specializes in the development of data drivers and data access technologies for real-time access to online or on-premise applications, databases and web APIs. The company is focused on bringing data connectivity capabilities natively into tools organizations already use. It also features ETL/ELT solutions, enterprise connectors, and data visualization. Matillion ’s data transformation software empowers customers to extract data from a wide number of sources, load it into their chosen cloud data warehouse (CDW) and transform that data from its siloed source state, into analytics-ready insights – prepared for advanced analytics, machine learning, and artificial intelligence use cases. Only Matillion is purpose-built for Snowflake, Amazon Redshift, Google BigQuery, and Microsoft Azure, enabling businesses to achieve new levels of simplicity, speed, scale, and savings. Trusted by companies of all sizes to meet

2022: The year of hybrid work

Remote work was once considered a luxury to many, but in 2020, it became a necessity for a large portion of the workforce, as the scary and unknown COVID-19 virus sickened and even took the lives of so many people around the world.  Some workers were able to thrive in a remote setting, while others felt isolated and struggled to keep up a balance between their work and home lives. Last year saw the availability of life-saving vaccines, so companies were able to start having the conversation about what to do next. Should they keep everyone remote? Should they go back to working in the office full time? Or should they do something in between? Enter hybrid work, which offers a mix of the two. A Fall 2021 study conducted by Google revealed that over 75% of survey respondents expect hybrid work to become a standard practice within their organization within the next three years.  Thus, two years after the world abruptly shifted to widespread adoption of remote work, we are declaring 20