You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue has been previously reported in issues #167, #46, and #29, but has not been fully resolved as the underlying root cause remains unaddressed.
Problem Description
I have observed that the playwright fixture installs a running event loop in the current thread. This behavior leads to subsequent calls to asyncio's run or similar functions becoming unsuccessful. Due to the abstract nature of the Playwright code, I have not yet pinpointed the exact source of the problem.
Additionally, I am unable to reproduce this issue by directly invoking the asyncio API within basic Python scripts not involving Playwright, so I don't really understand the mechanics at play here.
Reproduction
I have created a minimal reproduction repository to demonstrate the issue. Here is a sample test file that highlights the problem:
In this script, any asynchronous test that follows a test using the playwright fixture results in an error. Changing the test order or skipping the test_pw_true test, which is currently empty, prevents the issue from occurring.
Suggested Solution
One potential solution could be to initialize Playwright in a separate thread or process, with the Pytest API offering a wrapper to handle inter-thread communication. However, this approach might be overly simplistic and may need further refinement.
Temporary Workaround
While awaiting a more permanent and clean solution, I will continue using the hacks mentioned in the above issues. Nonetheless, a robust and canonical fix would be greatly appreciated.
Thank you!
The text was updated successfully, but these errors were encountered:
I have run into this as well. Please add a warning to the documentation, as this means the package is outright incompatible with anything that requires an async test method, because the system under test is asynchronous. It appears that this is the sole reason I cannot use this package and will have to resort to using the JS version of Playwright instead (which comes with the additional overhead of not being able to reuse existing Python fixtures) (not a rant, just an explanation of why this has a bigger impact than it may seem at first).
Summary
This issue has been previously reported in issues #167, #46, and #29, but has not been fully resolved as the underlying root cause remains unaddressed.
Problem Description
I have observed that the
playwright
fixture installs a running event loop in the current thread. This behavior leads to subsequent calls to asyncio'srun
or similar functions becoming unsuccessful. Due to the abstract nature of the Playwright code, I have not yet pinpointed the exact source of the problem.Additionally, I am unable to reproduce this issue by directly invoking the
asyncio
API within basic Python scripts not involving Playwright, so I don't really understand the mechanics at play here.Reproduction
I have created a minimal reproduction repository to demonstrate the issue. Here is a sample test file that highlights the problem:
In this script, any asynchronous test that follows a test using the
playwright
fixture results in an error. Changing the test order or skipping thetest_pw_true
test, which is currently empty, prevents the issue from occurring.Suggested Solution
One potential solution could be to initialize Playwright in a separate thread or process, with the Pytest API offering a wrapper to handle inter-thread communication. However, this approach might be overly simplistic and may need further refinement.
Temporary Workaround
While awaiting a more permanent and clean solution, I will continue using the hacks mentioned in the above issues. Nonetheless, a robust and canonical fix would be greatly appreciated.
Thank you!
The text was updated successfully, but these errors were encountered: