From 649aba094e2f7bdb4d890122bd75d8f98e2820e0 Mon Sep 17 00:00:00 2001 From: Alex Plischke Date: Wed, 17 Apr 2024 10:33:51 -0700 Subject: [PATCH] docs: playwright remote connection (#2735) --- .../playwright/selenium-grid.md | 45 +++++++++++++++++++ sidebars.js | 1 + 2 files changed, 46 insertions(+) create mode 100644 docs/web-apps/automated-testing/playwright/selenium-grid.md diff --git a/docs/web-apps/automated-testing/playwright/selenium-grid.md b/docs/web-apps/automated-testing/playwright/selenium-grid.md new file mode 100644 index 0000000000..c56d07f0ca --- /dev/null +++ b/docs/web-apps/automated-testing/playwright/selenium-grid.md @@ -0,0 +1,45 @@ +--- +id: selenium-grid +title: Selenium Grid +sidebar_label: Selenium Grid +--- + +Playwright can also connect to Sauce Labs remotely via its [Selenium Grid +support](https://playwright.dev/dotnet/docs/selenium-grid) to launch the Google +Chrome or Microsoft Edge browser. + +Playwright connects to the browser using the Chrome DevTools Protocol (CDP). +Selenium 4 _currently_ exposes this capability. + +:::caution +This feature is highly experimental, both from a Playwright's perspective, as +well as Sauce Labs. This integration may stop working at any time without due +notice. +::: + +# Connect Playwright to Sauce Labs + +To let Playwright connect remotely to Sauce Labs, you need to set two +environment variables: `SELENIUM_REMOTE_URL` and `SELENIUM_REMOTE_CAPABILITIES`. + +```shell +SELENIUM_REMOTE_URL=https://ondemand.us-west-1.saucelabs.com:443/wd/hub \ +SELENIUM_REMOTE_CAPABILITIES='{"platformName":"Windows 11","browserName":"chrome","sauce:options":{"devTools":true,"username":"your_user","accessKey":"your_access_key"}}' \ +npx playwright test --headed --project "your-chromium-project" +``` + +:::note +`--headed` must be specified for our platform to capture a video. +::: + +:::note +`--project` must be specified to match the browser you are targeting in the +`SELENIUM_REMOTE_CAPABILITIES` environment variable. +::: + +# Limitations + +The remote session has no knowledge of the _tests_ you are running. Since the +browser is mainly communicating with Playwright via CDP, there are only the most +rudimentary Selenium commands that are listed in the Sauce Labs UI: to start and +close the session. \ No newline at end of file diff --git a/sidebars.js b/sidebars.js index 8a9193f937..6123deb7d4 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1507,6 +1507,7 @@ module.exports = { items: [ 'web-apps/automated-testing/playwright', 'web-apps/automated-testing/playwright/quickstart', + 'web-apps/automated-testing/playwright/selenium-grid', 'web-apps/automated-testing/playwright/yaml', 'web-apps/automated-testing/playwright/advanced', ],