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.

Intercept requests

Intercept requests

In this section, we'll learn some techniques which can be used to optimize our tests. In this lesson, we will learn how to skip over the resources which our test does not require. That is, by default, if we initiate any page navigation, Playwright goes ahead and loads every resource as you'd expect, that is the images, the fonts, the stylesheets, and the other things. So if I go ahead and run our test, you can see we launch the browser, load in the images, the stylesheet, and then carry on with our test. At the end, we also get the total time taken to execute the two tests that is 5.42 seconds now here what our test does is checks whether or not our page has a link with the doc's name inside of the same and for the second test we go ahead and click on the get started button and make sure the page url is the docs url. In both of these tests, we are not bothered with the images, the style sheet, or any other thing in the website. We only need the html data, that is the links, the…

Contents