playwright-pytest icon indicating copy to clipboard operation
playwright-pytest copied to clipboard

Playwright starts browser in headed mode when called from VS Code Debugger - even on headless server

Open pearzt opened this issue 3 years ago • 2 comments

The current implementation starts the browser in headed mode automatically, if pytest is invoked from VS Code's debugger.

https://github.com/microsoft/playwright-pytest/blob/68bd92a133eeac597da61a0819768a589dafd6dd/pytest_playwright/pytest_playwright.py#L118-L120

While I get the idea behind this, it does not take remote development on a headless server into account. If $DISPLAY is not set, the test run naturally fails and leaves the user wondering why this happens because he did not provide --headed (e.g. in VS Code's python.testing.pytestArgs configuration). IMHO, the implementation should be changed to check for $DISPLAY at least.

pearzt avatar Jul 21 '22 13:07 pearzt

Had this issue today when using VSCode Python Extension (v2023.14.0) Test debugger in WSL2.

Worked around it by changing the above setting but be great to know if this could be more configurable.

Sparrow0hawk avatar Sep 07 '23 13:09 Sparrow0hawk

Happy to accept patches about this to include an if with something like:

no_supported_display = sys.platform == "linux" and os.getenv("DISPLAY")
elif VSCODE_PYTHON_EXTENSION_ID in sys.argv[0] and _is_debugger_attached() and not no_supported_display`: 

(just put it quickly there, might need different conditions etc)

mxschmitt avatar Sep 07 '23 16:09 mxschmitt