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.

Headful / headed runs failing on GitHub Actions (python-playwright / Chromium / Linux)

See original GitHub issue

I can’t get headful runs to work using python-playwright; I keep getting Unable to open X display..

I’ve tried for months with the recommended setup at https://playwright.dev/python/docs/ci#running-headed, and just today tried adding --server-args="-screen 0 1280x960x24" to the xvfb-run command to match your (passing) example here, but it’s still not working.

I got some errors about the Chromium sandbox, so I added

chromium_sandbox=False,
args=["--no-sandbox", "--disable-setuid-sandbox"],

but that didn’t seem to help.

Currently on python 3.9.5, python-playwright 1.11.0, Ubuntu-20.04.

You can see my config at: https://github.com/n8henrie/pycookiecheat/blob/dev/.github/workflows/python-package.yml

At the time of opening this issue, it is:

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
  push:
    branches: [ master, dev ]
  pull_request:
    branches: [ master, dev ]

jobs:
  build:
    runs-on: ubuntu-20.04
    strategy:
      matrix:
        python-version: [3.7, 3.8, 3.9]

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - uses: microsoft/playwright-github-action@v1
    - name: Install tox
      run: python -m pip install tox
    - name: Run tox
      run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- python -m tox -e py
    - name: Lint
      run: python -m tox -e lint

You can see my dozens of failing attempts to get this to run at: https://github.com/n8henrie/pycookiecheat/actions – I’d love to hear any suggestions!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
n8henriecommented, Aug 26, 2021

@mxschmitt – You’re correct, it had to do with tox clearing the environment variables.

Specifically, adding this to my GitHub Actions yaml file resolved the issue:

  env:
      TOX_TESTENV_PASSENV: "XAUTHORITY DISPLAY"

Full working example: https://github.com/n8henrie/pycookiecheat/blob/3458862a4c99c83ae9017fe52ae6ec49216c745d/.github/workflows/python-package.yml#L16

Alternatively, I could have used the passenv key in tox.ini.

This was such a pain to sort out that I wrote up a blog post of my procedure here.

Thanks for pointing me in the right direction!

0reactions
mxschmittcommented, Aug 26, 2021

Awesome news! 💯

Read more comments on GitHub >

github_iconTop Results From Across the Web

Headful runs failing · Issue #37 · microsoft/playwright ... - GitHub
im still trying to track down the reason doesn't seem to be related to playwright itself probably something changed in the github actions...
Read more >
[Question] Issue with launching Chromium in headful mode
Hey guys. From time to time I face an issue with running PW with chromium in headful mode. PW starts chromium and chromium...
Read more >
[BUG] Chromium instability on self hosted github actions ...
Context: Playwright Version: 1.21.1 Operating System: Linux Node.js version: 16.11.0 Browser: Chromium Extra: Running within self hosted ...
Read more >
[Question] chromium with head #4486 - microsoft/playwright
Hello, I've got a question regarding running chromium with head. It's very weird behaviour because I can run locally with the head but...
Read more >
[BUG] Test fails when running headed mode #12552 - GitHub
[BUG] Test fails when running headed mode #12552 ... On a simple example the pdf is opened in the builtin viewer in headful...
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