From the course: Playwright Essential Training: Abstractions, Fixtures, and Complex Scenarios

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Intercepting HTTP requests with Playwright

Intercepting HTTP requests with Playwright

- [Instructor] Now that you've heard a lot of different ways to work with page routes and network traffic and playwright, let's go ahead and implement one of these methods. We are going to implement the intercepting traffic from the network and we want to use that data that we get from the network in our tests for our assertions. So for this example, we'll go to the practice website. I've right clicked and opened my inspector window. I've opened the network tab and I've actually cleared it out. So we've got a clean slate, I'm going to refresh the page and I've actually narrowed down my network request to just fetch XHR requests. And I'm looking for this products API call. So this is a API call here. I'm going to go ahead and copy this. It's a get request. We're just passing in a price in between 1 and 100. And this is the data that comes back. And we can see this is a json object and there is a data section, which it looks like has an array of objects, which should include, you know…

Contents