Skip to content

Using async in pyppeteer test, opened several browsers, but only the last one can run, the others fail to location. #224

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

Closed
heliping opened this issue Aug 4, 2021 · 3 comments

Comments

@heliping
Copy link

heliping commented Aug 4, 2021

I use pytest asyncio function with pyppeteer to test the web UI.

the testcase like this:

@pytest.mark.asyncio
async def test_lock_remote(): 
     await  xxxxxx

@pytest.mark.asyncio
async def test_lock_onsite(): 
      await xxxxxx

but the first case can be interrupt by the second one. and the second one can success, the first one always fails, and lost its mouse focus.

@heliping heliping changed the title use async in pyppeteer test, opened several browsers, but only the last one can run, the others fail to location. Using async in pyppeteer test, opened several browsers, but only the last one can run, the others fail to location. Aug 4, 2021
@simon-liebehenschel
Copy link

@heliping Could you please add pyppeteer, Python, pytest, pytest-asyncio versions to your message?

@asvetlov
Copy link
Contributor

asvetlov commented Jan 8, 2022

Sorry, the bug report has no reproducible example.

@seifertm
Copy link
Contributor

@heliping Judging from #91 pyppeteer uses asyncio tasks for clean up purposes. The default event_loop fixture of pytest-asyncio creates a new loop for each of your test cases. Issue #91 shows that this can cause the cleanup to fail in some cases. You can try using a session scoped event_loop fixture and see if it solves your problem:

@pytest.fixture(scope="session")
def event_loop():
    loop = asyncio.get_event_loop_policy().new_event_loop()
    yield loop
    loop.close()

As @AIGeneratedUsername and @asvetlov already mentioned we need more information to help you out. Feel free to reopen this issue, If you can provide a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants