docs: Update WebDriver BiDi docs on v21.6.0 (#11541)

This commit is contained in:
Jecelyn Yeen 2023-12-13 18:26:33 +08:00 committed by GitHub
parent af9aebed33
commit 3f9d2b5c8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,36 +1,35 @@
# Experimental WebDriver BiDi Support # Experimental WebDriver BiDi support
[WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) is a new cross-browser [WebDriver BiDi](https://w3c.github.io/webdriver-bidi/) is a new cross-browser
automation protocol that adds browser-driven events to WebDriver. Here are the automation protocol currently under development, aiming to combine the best of both WebDriver “Classic” and CDP. WebDriver BiDi promises bi-directional communication, making it fast by default, and it comes packed with low-level control.
resources if you want to learn more about WebDriver BiDi:
See also:
- [WebDriver BiDi - The future of cross-browser automation](https://developer.chrome.com/articles/webdriver-bidi/) - [WebDriver BiDi - The future of cross-browser automation](https://developer.chrome.com/articles/webdriver-bidi/)
- [WebDriver BiDi: 2023 status update](https://developer.chrome.com/blog/webdriver-bidi-2023/) - [WebDriver BiDi: 2023 status update](https://developer.chrome.com/blog/webdriver-bidi-2023/)
## Automate with Chrome and Firefox ## Automate with Chrome and Firefox
Firefox support has almost reaching feature parity with the previous CDP-based Puppeteer supports WebDriver BiDi automation with Chrome and Firefox.
implementation. To see which features are fully supported with WebDriver BiDi we
used the [Puppeteer test suite](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/). Currently,
we still have fewer than
[60](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json)
tests that are failing with Firefox and WebDriver BiDi compared to the previous
CDP implementation in Firefox but we also have more than
[82](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json)
new tests that work with WebDriver BiDi and that didn't work with CDP.
For Chrome, around 68% of the tests are currently passing with WebDriver BiDi so Firefox integration is nearing feature parity with its previous CDP-based approach. Learn more in the [dedicated announcement](https://hacks.mozilla.org/2023/12/puppeteer-webdriver-bidi/).
the CDP-based implementation remains more powerful. Some of the Puppeteer
functionality is relying on CDP even with WebDriver BiDi enabled. Therefore, the
test pass rate is currently higher than that one of Firefox.
Example of launching Firefox with WebDriver BiDi: ## Measuring progress
To gauge the capabilities of WebDriver BiDi, we utilized the comprehensive [Puppeteer test suite](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/)
- For Firefox, there are currently under [60](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json) failing tests compared to the CDP implementation, while over [82](https://puppeteer.github.io/ispuppeteerwebdriverbidiready/firefox-delta.json) new tests successfully utilize WebDriver BiDi, demonstrating its growing potential.
- For Chrome, around 68% of tests pass with WebDriver BiDi, indicating room for improvement compared to the CDP-based approach.
## Get started
Below is an example of launching Firefox or Chrome with WebDriver BiDi:
```ts ```ts
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({ const browser = await puppeteer.launch({
product: 'firefox', product: 'firefox', // or 'chrome'
protocol: 'webDriverBiDi', protocol: 'webDriverBiDi',
}); });
const page = await browser.newPage(); const page = await browser.newPage();
@ -38,19 +37,7 @@ const page = await browser.newPage();
await browser.close(); await browser.close();
``` ```
Example of launching Chrome with WebDriver BiDi: This is an exciting step towards a more unified and efficient cross-browser automation experience. We encourage you to explore WebDriver BiDi with Puppeteer and join us in shaping the future of browser automation.
```ts
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({
product: 'chrome',
protocol: 'webDriverBiDi',
});
const page = await browser.newPage();
...
await browser.close();
```
## Puppeteer features supported over WebDriver BiDi ## Puppeteer features supported over WebDriver BiDi