[BUG] Playwright is not running tests on Selenium Grid + Docker
See original GitHub issueContext:
- Playwright Version: 8.1.2
- Operating System: Linux (5.10.60.1-microsoft-standard-WSL2)
- Node.js version: 16.13.2
- Selenium Grid version: 4.1.1
- Browser: Chrome (v.97.0)
- Extra: The operating system is an image of Linux on Docker Desktop version 4.4.3 (73365) running through Windows 10.
Bug description
I’m trying to run some Playwright (Node.js) tests on Docker through Selenium Grid, but the tests are failing because of timeout. Chrome is apparently not starting. Locally without Docker everything is fine.
According to the Playwright documentation, it would be enough to run the tests using the following command:
SELENIUM_REMOTE_URL=http://localhost:4444/wd/hub npx playwright test
But that is not working.
I’m building the environment in Docker by running the following file through Powershell:
$maxNodes = 1
function GetImages()
{
docker pull selenium/hub:latest
docker pull selenium/node-chrome:latest
}
function CreateGrid()
{
docker network create grid
}
function CreateHub()
{
docker run -d -p 4442-4444:4442-4444 --net grid --name hub selenium/hub:latest
}
function CreateNodes()
{
$nodes = 1
while($nodes -le $maxNodes)
{
docker run -d -P --net grid -e SE_EVENT_BUS_HOST=hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SE_NODE_SESSION_TIMEOUT=120 selenium/node-chrome:latest
$nodes++
}
}
cls
GetImages
CreateGrid
CreateHub
CreateNodes
cls
Write-Host "HUB AND NODES CREATED!!"
The config from playwright.config.ts is:
import { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
timeout: 20000,
workers:1,
use: {
baseURL: 'https://www.google.com',
viewport: { width: 1280, height: 720 },
browserName: "chromium",
channel: "chrome",
headless: false
}
};
export default config;
And the test running is:
test('Acessar Google', async ({ page }) => {
await page.goto('/');
const length = await page.locator('input[type=submit]').count();
expect(length >= 1).toBeTruthy();
});
In Docker Selenium Grid, the following is displayed:
The session is “empty” with nothing running. The browser has a blank page.
After running the tests using the above mentioned command, the result is as follows.
I think this is a bug. If anyone can help, I’d be grateful.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:15 (1 by maintainers)
@John-Yue-Deltatre As mentioned i added the my selenium grid url under the SE_NODE_GRID_URL=http://ipaddress:port/wd/hub. This resolves the problem and everything is cleared. Thanks
We were facing the same issue. We have updated the below environment variable in our docker-compose.yaml file.
- SE_NODE_GRID_URL=http://localhost:4444/
After adding above variable, tests are running on selenium grid 4 with playwright.
Can we add this in the new version of selenium grid. ??
https://newreleases.io/project/github/SeleniumHQ/docker-selenium/release/4.1.1-20211217