Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 455
talgreen Avatar asked Oct 23 '25 10:10

talgreen


1 Answers

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.

like image 120
Max Avatar answered Oct 25 '25 00:10

Max