3

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!!"

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

Terminal error

In Docker Selenium Grid, the following is displayed.

Selenium Grid session

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

Selenium Grid session view

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(); 
});

I don't know what could be going wrong. Can anyone help me?

  • Can you add the proper stack trace error to the issue? Also, did you try to execute the test locally and move up the stack (locally, single container, and finally grid) to isolate some of the problems? – Leonardo Galani Jan 26 '22 at 11:06
  • @LeonardoGalani That's the problem because there is no stacktrace error. It's just timeout error apparently because the browser is not running. Locally everything is fine. Single container I have same problem. – Octávio Moreira Jan 26 '22 at 12:40
  • @LeonardoGalani after some adjusts the browser appears but its blank :/ I updated the problem description to make it easier to see. – Octávio Moreira Jan 26 '22 at 18:00
  • I suggest you spin up the playwright container with bash (and matching volume) to see if you can run your script without the grid. (its also a good way to debug proxy/port issues) – Leonardo Galani Jan 31 '22 at 09:07
  • I opened a bug: https://github.com/microsoft/playwright/issues/11692#issuecomment-1023645784 – Octávio Moreira Feb 08 '22 at 05:42

0 Answers0