'How to run Playwright test from Pycharm in headed mode

I'm using Python & Pytest to write Playwrite tests. PyCharm is the my IDE.

When I'm debugging a test - I run it from the IDE (by pressing the play icon next to the test). I would like to be able to view the browser during the run in order to debug.

The problem is that when using the 'page' fixture - the default mode is headless.

I know that I can run the test from the CLI and add the flag '--headed', but I want to run headed also by running from the IDE.

Is that possible?



Solution 1:[1]

Yes, this is possible! Just create or add to your pytest.ini file which should go in the root of the working directory.

Here is what the pytest.ini file could look like:

# content of pytest.ini
[pytest]
addopts = -v --browser chromium --headed --slowmo 2000

Having --headed in there is what gives you what you want.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Max