Closed authauthentic8 closed 5 months ago
In my case I've created a simple function:
def wrapped_click(locator):
locator.wait_for()
locator.click()
without it Playwright seems to be... too fast?
I guess it depends also on how the frontend is built (I have an app which is over 10 years old, so there are parts which doesn't meet current standards of UI dev).
@aspenboy Was this on the popup page of a chrome extension? I have the same thing you're suggesting for the other pages of my extension and it works fine. It's only on the popup.html page of my extension that i have to use a time.sleep(3) before trying to interact with a locator.
@aspenboy I just realized that wasn't included in the original post. I narrowed it down to the popup.html page after I made this post.
Sounds not like a Playwright issue and more like an issue of the extension you are testing. Playwright is like a very fast user, and often this is too fast for the websites users are testing, ending up in race conditions, hydration issues etc.
Closing as per above. Feel free to re-file for further questions.
HI Playwright team!
I'm having an issue reliably interacting with page elements that is currently only being solved by using a time.sleep(3) before trying to click or expect an element to be on the page.
I'm using VScode on a MacBook with Ventura 13.5.1 and using sync playwright-pytest with python 3.10.
I'm creating a page from a context (for the extension I'm testing) that was generated in conftest.py and passed as an argument into my test.
Generating a context in conftest.py
or
These only seem to work with a pause from time.sleep(3) in front of them or the pause from the GUI inspector after navigating to the page and before trying to click or expect the element like this
or
I have tried:
element_locator.wait_for()
before trying to interact with the element.Any suggestions for how to accomplish this in a more dynamic way than using time.sleep()? Using a static wait like this isn't going over well at work. :/