NoamGaash / playwright-advanced-har

MIT License
26 stars 0 forks source link

playwright bot not working with custom "test" fixture #22

Open wahreChrist opened 1 month ago

wahreChrist commented 1 month ago

Hey Noam,

I saw your issue in playwright forums when I was looking for a solution for our use case. In short: I have been trying to sanitize our har files, so they wouldn't save sensitive information with routeFromHar method. It seemed to me that you already did all the heavy lifting with your package, and I was trying to implement it in our project. Unfortunately, I haven't been able to make it work yet: your package requires import of modified "test" fixture, to have access to advancedRouteFromHAR method, but when Im trying to run tests with your fixture, playwright bot just dont execute any actions, apart from navigating to a certain url. Have you encountered this issue before? Perhaps you know how to fix it? It looks like your package already has all the necessary functionality for us, and I wouldnt want to mess too much with playwrights source code just to make something similar in the end.

Best regards,

Artem L

NoamGaash commented 1 month ago

Hi Artem, thanks for the feedback! Could you please help me reproduce this error? Also, if you need to import test from somewhere else, you can use Playwright's mergeTests method

wahreChrist commented 1 month ago

Sorry for the late response, have been busy with other things. I have managed to make the package work, we have quite complicated setup ourselves, so it was not really straightforward to make it work right away. Now I can run our tests with your fixture and record har files, like with the default routeFromHar method, but there are still a few issues that I faced since then and would like to ask regarding how to implement my use case with your package, if it's fine by you? As I initially described in the original post, I need to either skip recording of some requests, to avoid storing sensitive information in hars, or edit those specific request bodies afterward, to replace that information with placeholders. The first option has a downside though: I will need to provide extra logic to handle those requests in the future when I play them back while running tests offline and locally. So firstly, I just wanted to ask if any of those approaches can be handled by your package and already included methods there, and if yes could you point me in the right direction, so to say, which one should I use in each case. Secondly, I have been trying to implement the second approach, by just intercepting inside postProcess method an entry.request.postData.text and then modifying it to have placeholders instead of passwords, we do similar approach with regular playwright route method on some tests, but the goal here to do it not with real request bodies on the fly, but just with har recordings. I have faced a couple of issues here along the way though:

Thanks in advance for the help.