robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

Add support for browserContext.routeFromHAR

Open leeuwe opened this issue 3 years ago • 3 comments

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

leeuwe avatar Sep 07 '22 12:09 leeuwe

Sounds like a good idea, are planning to provide also PR for the implementation?

aaltat avatar Sep 07 '22 13:09 aaltat

After Robocon DE I'm hoping to provide a PR - yes. Now I haven't got time

leeuwe avatar Sep 07 '22 13:09 leeuwe

Really nice @leeuwe !

mkorpela avatar Sep 07 '22 20:09 mkorpela

@Snooz82 @mkorpela @aaltat What would you think? Should this fit better in core browser, of shall I use the new plugin API?

leeuwe avatar Jan 14 '23 21:01 leeuwe

Good question. The problem with New Context is, that it is already oversized by arguments.

But an additional keyword is also not that good.

Snooz82 avatar Jan 14 '23 21:01 Snooz82

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.

mkorpela avatar Jan 17 '23 18:01 mkorpela

// 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?

mkorpela avatar Jan 17 '23 18:01 mkorpela

Implementing elsewhere. Closing issues

leeuwe avatar Jan 17 '23 19:01 leeuwe