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.
Mocking HTTP responses with Playwright - Microsoft Playwright Tutorial
From the course: Playwright Essential Training: Abstractions, Fixtures, and Complex Scenarios
Mocking HTTP responses with Playwright
- [Instructor] Another approach to working with network requests in Playwright is to override certain things in the response or to fully mock the network request. We'll walk through both of these examples in this video. So let's go back to our home spec and we're just going to go ahead and create a new test at the bottom down here. The test will be to validate the first one. Validate product data is visible from modified API, add our test information here. All right, so I think we should have a valid test framework here and we're just going to go ahead and copy this test step up here. We'll paste this here. So we're going to intercept, I'm actually going to say we're going to overwrite the products in point. It's very similar context, but there's some slight differences. So hopefully you get to see those here. So we've got our paid route, we've got the endpoint we want to route to, we have our awaitroute.fetch. The next thing we want to do is create a JSON variable. I'm going to set…
Contents
-
-
-
-
-
(Locked)
Overview of network routing in Playwright5m 8s
-
(Locked)
Intercepting HTTP requests with Playwright13m 32s
-
(Locked)
Mocking HTTP responses with Playwright11m 14s
-
(Locked)
Browser emulation in Playwright9m 35s
-
(Locked)
Localization and geolocation in Playwright3m 45s
-
(Locked)
Injecting JavaScript in Playwright11m 11s
-
(Locked)
Challenge: Mocking and emulation in Playwright1m 29s
-
(Locked)
Solution: Mocking and emulation in Playwright6m 53s
-
(Locked)
-
-
-