Mock the response of a request. You can define a mock based on a matching glob and corresponding header and status code. Calling the mock method returns a stub object that you can use to modify the response of the web resource.
With the stub object you can then either return a custom response or have the request fail.
There are 3 ways to modify the response:
- return a custom JSON object (for stubbing API request)
- redirect resource to a different url
Note that using the
mock command requires support for Chrome DevTools protocol and e.g.
can not be used when running automated tests in the cloud. Find out more in the
Automation Protocols section.
|url||url to mock|
|filter mock resource by additional options|
|filter resource by HTTP method|
|filter resource by specific request headers|
|filter resource by specific response headers|
|filter resource by request postData|
|filter resource by response statusCode|