playwright/docs/src/selenium-grid.md
2021-10-18 11:24:30 -07:00

1.3 KiB

id title
selenium-grid Selenium Grid

Playwright can connect to Selenium Grid Hub to launch Chrome browser, instead of running browser on the local machine. To enable this mode, set SELENIUM_REMOTE_URL environment variable pointing to your Selenium Grid Hub.

# Playwright Test
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub npx playwright test

# Playwright Library
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub node script.js
# With Pytest
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub pytest --browser chromium

# Plain Python
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub python script.py
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub mvn test
SELENIUM_REMOTE_URL=http://internal.grid:4444/wd/hub dotnet test

You don't have to change your code, just use [method: BrowserType.launch] as usual.

When using Selenium Grid Hub, you can skip browser downloads.

:::note Internally, Playwright connects to the browser using Chrome DevTools Protocol websocket. This requires Selenium Grid nodes to be directly accessible from the machine that runs Playwright. :::