Closed Rafiot closed 7 months ago
Add a way to forcefully trigger the locator handlers?
You can extract the handler in a function and call it whenever you want in the tests, would that work for you?
I could, but I have a bunch of them (currently 6, most probably many more later) and using the locator handler seemed like a cleaner way to do it (?).
But, now you say that, internally, they are all triggered sequentially, right?
I could, but I have a bunch of them (currently 6, most probably many more later)
You have flexibility to chose which one you need or you can wrap all of them in a function too.
and using the locator handler seemed like a cleaner way to do it (?).
Locator handlers are only triggered during an action/assertion, I'm updating the docs to make it more clear.
But, now you say that, internally, they are all triggered sequentially, right?
Yes.
Page(s)
https://playwright.dev/docs/api/class-page#page-add-locator-handler
Description
So I hope I'll not be hurting your soul too much with that one, but I really need to trigger the locator handler at an arbitrary time without doing anything else (I need to be able to bypass the cookies authorization on arbitrary websites).
My workaround is to run do that:
await page.locator("body").click(button="right")
Which does nothing, but triggers the locator handlers whenever I want them triggered.
The full commit looks like that:
https://github.com/Lookyloo/PlaywrightCapture/commit/26348f7bf5f28f7d6c6a6d48cb41fe77ed99f6f5
Maybe two things: