4

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?

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Apr 10, 2022 at 14:39

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
make sure you install 'pip3 install pytest-playwright' before you start in your python interpreter
0
  1. Open Preferences, tab "Python Integrated Tools"
  2. Set Default test runner as pytest default test runner
  3. Go to edit configurations in the Run/Debug Configurations Run/Debug configurations
  4. Add a new pytest configuration (plus sign)
  5. Set "Target" as "Custom" and then write whatever flags you want to use in the "Additional Arguments" input field enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.