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.

Take screenshot

Take screenshot

In this section, we'll learn about the playwright tools which we can use when writing our tests and debugging the same. In this lesson, we'll learn how can we take screenshot of our page at a certain moment. Let's say when we visit the playwright website, we'd like to take a screenshot of the same. So right after we do this go to or navigation, we can use our page object and use the screenshot method. To the screenshot method, we can provide a path to where to save our screenshot or our image file. So here I'll just provide it the current directory and the name of the file, which will be let's say playwright.png. Now you can use the png or jpeg format as well, whichever you prefer. And now if we go ahead and run our test, when it will visit the page, it will go ahead and take a screenshot as well. So let's go ahead and run our test. You can see it opens our test function, passes the same. And now if you take a look at the explorer, you will see playwright.jpeg. And if I open the same,…

Contents