Add support for browserContext.routeFromHAR
I'd like to extend New Context keyword to allow testing with prerecorded data. Recording the HAR is already possible, now I want to use this HAR as MOCK.
New in PlayWright 1.23 https://playwright.dev/docs/api/class-browsercontext#browser-context-route-from-har
Sounds like a good idea, are planning to provide also PR for the implementation?
After Robocon DE I'm hoping to provide a PR - yes. Now I haven't got time
Really nice @leeuwe !
@Snooz82 @mkorpela @aaltat What would you think? Should this fit better in core browser, of shall I use the new plugin API?
Good question.
The problem with New Context is, that it is already oversized by arguments.
But an additional keyword is also not that good.
Recorded mock would be pretty nice way to make tests and also at the same time our New Context is bloated with arguments.
Somehow would be great to create a way where one could state that in this suite / test we are using this mock.
// Replay API requests from HAR.
// Either use a matching response from the HAR,
// or abort the request if nothing matches.
await page.routeFromHAR('example.har');
@leeuwe as this seems rather easy to implement with a python plugin or JS extension.. Maybe start with that?
Implementing elsewhere. Closing issues