-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Expose Playwright async/await flavor #74
Comments
Exactly, currently the pytest plugin does only provide the sync APIs. So you need to launch browser etc. yourself, something similar to https://github.com/microsoft/playwright-python/blob/master/tests/async/conftest.py Shall I rename this issue title into a feature request for providing also the async flavor? |
Thanks.
Sure, go ahead. |
pytest-playwright
is not compatible with aiohttp
@mxschmitt I'm on Playwright v1.17 and I did try to copy-paste all the fixtures in the file you pointed here (except the
I quickly fixed it by changing
I'm pretty new to Python and pytest but I guess |
@dwiyatci why do you prefer async over sync? Understanding this use-case for the testing scenario would us help to prioritize it. |
@mxschmitt I would like to implement a custom |
@mxschmitt: I want to use this plugin together with aiohttp-pytest, because my project is based on aiohttp. Thats the reason why @maratori and i prefer (in this case) async over sync. |
any updates for this feature? |
It is very odd that there are async/sync versions of Playwright Python but the integration with pytest only supports sync. If the primary purpose of Playwright is to write tests, but the async version cannot be used with the dominant test framework, then what is the async version's purpose? If the async version is intended for applications other than testing, then this is still odd as we'd likely want to use pytest to test that code. On a more pragmatic level, as more and more applications are written using async libraries, more and more tests will need to be async. Also, having async tests allows us to use some cleaner semantics for things like processes that happen in parallel. There's also the issue (microsoft/playwright-python#1339 (comment)) I ran into that we can't even mix async/sync tests in the same test suite and use @mxschmitt, do you have pointers on how hard this would be/what would need to be done? |
@nathanielobrown I totally agree that providing an async layer would be cool! The reason why we didn't do it yet was that its more idiomatic to write tests in sync mode (debugging, you don't need to install other pytest plugins, REPL just works etc). Regarding how hard it is to implement, I think it hardly depends on the question how much code we want to duplicate. In general the pytest-playwright plugin is not a lot of code, to provide an async version, we could in theory just copy it and use the async version of Playwright and it should just work™️ . Something where I'm not sure about is if we need a dedicated plugin (PIP package) for the async version or if we can internally detect somehow if its async or sync and then do conditional logic. This requires some investigation. (happy to accept patches for it, just not something we prioritise, since not a lot of users have requested it so far.) |
@mxschmitt, that's great to hear there is no technical blocker. My initial thought would be to add new fixtures to the same package with Also this fix (microsoft/playwright-python#1339 (comment)) for the multiple event loops issue just worked from me and is topical. I'll probably work something up locally and if it works well can create a PR. |
Hey guys! |
Waiting for the async feature in pytest! |
Hey! What is the status of the feature? |
Hi! Any update? We need this as well :) |
We also need this feature to fully adopt playwright in our integration tests. |
Please prioritize higher to implement the python - Playwright with async. |
I need to run
aiohttp
server and useplaywright
in tests at the same time.Am I right that
pytest-playwright
right now can't help me with that?It provides fixtures only for sync API. But I need async API.
So I have to do something like that.
The text was updated successfully, but these errors were encountered: