From the course: Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Python debugger

Python debugger

In this lesson, we will learn how to use the Python debugger inside of a playwright test or any other playwright script. To do that, we can simply use the breakpoint function at the place where we like to break out. So let's say what we want to do is after locating the link element, we will go ahead and open the Python debugger using the breakpoint function. What it will do is open a interactive python shell where you can interact with the elements like the page and the link and execute python code line by line. So let's go ahead and run this test. Now we'll go ahead and only specify this test function using the key argument and the name of the function which is test page visits the docs. Now if I go ahead and run the browser, you can see when we have located the link element, we pause and the Python debugger has opened up, which is this right here. You can see the place where the debugger has paused and you have a prompt like this, where you can evaluate any Python expression. Let's…

Contents