Playwright: [BUG] Playwright on Azure Pipeline fails

Created on 19 Feb 2020  路  3Comments  路  Source: microsoft/playwright

Context:

  • Playwright Version: [0.11.0]
  • Operating System: [Ubuntu 18.04]
  • Extra: [Running on Azure Pipeline]

Hi all,
I can run all my tests (with jest) fine in my local but when I run same tests on Azure pipelines I get this errors (see bellow) and all tests fails, I think the browser (chrome is the only I see failing) fails to open?:

__Pipeline logs:__

# first error
/home/vsts/work/1/s/node_modules/playwright-core/.local-chromium/linux-740847/chrome-linux/chrome: error while loading shared libraries: libgbm.so.1: cannot open shared object file: No such file or directory

# and shortly after

    TypeError: Cannot read property 'close' of undefined

      52 |         }
      53 |       } catch (error) {
    > 54 |         await browser.close()
         |                       ^
      55 |         throw error
      56 |       }
      57 |     })

# and at the end

Test Suites: 3 failed, 3 total
Tests:       8 failed, 8 total
Snapshots:   0 total
Time:        3.908s
Ran all test suites matching /tests\//i.
  console.log tests/sign-in/singIn.test.js:27
    Error: Protocol error (Target.setDiscoverTargets): Target closed.
        at /home/vsts/work/1/s/node_modules/playwright-core/lib/chromium/crConnection.js:121:63
        at new Promise (<anonymous>)
        at CRSession.send (/home/vsts/work/1/s/node_modules/playwright-core/lib/chromium/crConnection.js:120:16)
        at Function.connect (/home/vsts/work/1/s/node_modules/playwright-core/lib/chromium/crBrowser.js:51:38)
        at Chromium.launch (/home/vsts/work/1/s/node_modules/playwright-core/lib/server/chromium.js:46:53)
        at Object.<anonymous> (/home/vsts/work/1/s/tests/sign-in/singIn.test.js:14:19) {
      message: 'Protocol error (Target.setDiscoverTargets): Target closed.'
    }

Test file:

const browserOptsPC = {
  viewport: {
    width: 1280,
    height: 768
  }
}

const browserLaunchOpts = {
  headless: true,
  dumpio: true,
  devtools: false
}

...

 try {
      for (const browserType of browsers) {
        browser = await playwright[browserType].launch(browserLaunchOpts)
        const context = await browser.newContext(browserOptsPC)
        const page = await context.newPage()
       // this is never executed:
        await page.goto(config.web)
        // ...
        await browser.close()
      }
    } catch (error) {
      console.log(error)
      await browser.close()
      throw error
    }

Azure pipeline file:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: npm install
  displayName: 'npm install'

- script: npm run test-e2e
  displayName: 'test-e2e'

Thank you :)

Most helpful comment

Hi @arjun27, thank you for your feedback!
With the dependencies installed now I can run playwright in Pipelines, there is no bug.. sorry for the label, I'll leave the final azure-pipelines.yml in case it helps others:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

steps:
# Install browser deps, starting with webkit
# https://github.com/microsoft/playwright/issues/1062
- bash: |
    which bash
    sudo apt-get install -y libwoff1 \
                       libopus0 \
                       libwebp6 \
                       libwebpdemux2 \
                       libenchant1c2a \
                       libgudev-1.0-0 \
                       libsecret-1-0 \
                       libhyphen0 \
                       libgdk-pixbuf2.0-0 \
                       libegl1 \
                       libnotify4 \
                       libxslt1.1 \
                       libevent-2.1-6 \
                       libgles2 \
                       libgl1 \
                       libegl1 \
                       libvpx5 \
                       libnss3 \
                       libxss1 \
                       libasound2 \
                       libdbus-glib-1-2 \
                       libxt6
  displayName: Multiline Bash script

- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: npm install
  displayName: 'npm install'

- script: npm run test-e2e
  displayName: 'test-e2e'

All 3 comments

Hi @juliomatcom! Looks like the Azure Pipelines base image is using Ubuntu 18.04 and is missing some system dependencies. You can find the list of dependencies to install here. Would it be possible to add them to your YML?

Additionally, I would also recommend using --no-sandbox as the launch args for Chromium as shown in this example.

We will put together getting started guides for using Playwright across CI providers, including Pipelines. Thanks for reporting this and helping us prioritize.

Hi @arjun27, thank you for your feedback!
With the dependencies installed now I can run playwright in Pipelines, there is no bug.. sorry for the label, I'll leave the final azure-pipelines.yml in case it helps others:

trigger:
- master

pool:
  vmImage: 'ubuntu-18.04'

steps:
# Install browser deps, starting with webkit
# https://github.com/microsoft/playwright/issues/1062
- bash: |
    which bash
    sudo apt-get install -y libwoff1 \
                       libopus0 \
                       libwebp6 \
                       libwebpdemux2 \
                       libenchant1c2a \
                       libgudev-1.0-0 \
                       libsecret-1-0 \
                       libhyphen0 \
                       libgdk-pixbuf2.0-0 \
                       libegl1 \
                       libnotify4 \
                       libxslt1.1 \
                       libevent-2.1-6 \
                       libgles2 \
                       libgl1 \
                       libegl1 \
                       libvpx5 \
                       libnss3 \
                       libxss1 \
                       libasound2 \
                       libdbus-glib-1-2 \
                       libxt6
  displayName: Multiline Bash script

- task: NodeTool@0
  inputs:
    versionSpec: '12.x'
  displayName: 'Install Node.js'

- script: npm install
  displayName: 'npm install'

- script: npm run test-e2e
  displayName: 'test-e2e'
Was this page helpful?
0 / 5 - 0 ratings

Related issues

myobie picture myobie  路  3Comments

shirshak55 picture shirshak55  路  3Comments

osmenia picture osmenia  路  4Comments

JoelEinbinder picture JoelEinbinder  路  4Comments

TrySound picture TrySound  路  4Comments