question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Playwright is not running tests on Selenium Grid + Docker

See original GitHub issue

Context:

  • 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:

image

The session is “empty” with nothing running. The browser has a blank page.

image

After running the tests using the above mentioned command, the result is as follows.

image

I think this is a bug. If anyone can help, I’d be grateful.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
BalajiMoorthy12commented, Jul 6, 2022

@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

3reactions
Nagam-Naiducommented, Jul 7, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Playwright is not running tests on Selenium Grid + Docker
I'm trying to run some Playwright (Node.js) tests on Docker through Selenium Grid, but the tests are failing because of timeout.
Read more >
#7 - Run Playwright Tests on Selenium 4 Grid ... - YouTube
Run Playwright Tests on Selenium 4 Grid [ Playwright Integration with Selenium Hub ]Schedule a meeting in case of any ...
Read more >
8 - Run Playwright Tests using Jenkins and Selenium 4 GRID
8 - Run Playwright Tests using Jenkins and Selenium 4 GRIDSchedule a meeting in case of any ...
Read more >
What Is Playwright – A Tutorial on How to Use ... - LambdaTest
This is essential for running larger suites of tests at scale and managing parallel execution through Selenium Grid. Features of Playwright testing framework....
Read more >
Naveen Khunteta on LinkedIn: #8 - Run Playwright Tests ...
Run Playwright tests using Jenkins on Selenium 4 GRID infrastructure. Next video coming soon on -> Run Playwright tests on Selenium 4 GRID...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found