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.

Overview of network routing in Playwright

Overview of network routing in Playwright

- [Instructor] In the first half of this chapter, we'll be diving into one of my favorite Playwright features, the ability to interact with the network traffic during a test. This functionality can take your test design to the next level. Here are a few examples of things you can accomplish with this. You can intercept network requests, you can abort certain network requests, you can modify network requests on what's returned to the UI, you can mock network requests, or you can even simulate a slow network, and there are tons of other opportunities, but in this video we're going to walk through a few examples demonstrating each one with code. First up, intercepting an API request. So this all happens within the page.route function that exists. So in this scenario, we are passing in the API for the products, so we get a list of products back, and we're routing that through this page router. We then set the response to whatever comes back from the response. We can then go in and set…

Contents