microsoft / playwright-python

Python version of the Playwright testing and automation library.
https://playwright.dev/python/
Apache License 2.0
11.89k stars 906 forks source link

[Bug]: page.goto do not work well at concurrent execution #2576

Closed ANewLearner-ali closed 1 month ago

ANewLearner-ali commented 1 month ago

Version

1.41

Steps to reproduce

i use plugin pytest-asyncio-cooperative==0.37.0 and pytest==8.3.3 to do my job. use a pool of broswer instance with a few context as my step fixture. there is my case code: @pytest.mark.asyncio_cooperative async def test_page_check_case_100(self, step: PageObject): await step.start() await step.open_page('交易动态-客户管理') await step.assert_page_valid(step.page.url) await step.end() my pageobject: def open_page(self, url): await self.page.goto(url, timeout=timeout)

and i add a route to record the request or playback.

await self.context.route(url, self.playback_handle)

async def playback_handle(self, route: Route, request: Request) -> None: "record the type and count of request, maybe fulfill or abort or continue_" pass

Expected behavior

it can run 200 case on 30 concurrent execution ,and all will be success. may be some case on "open_page" will be timeout

Actual behavior

In bad test case , "open_page" even do not happen timeout . it was a white page, page.goto() look success but not, event route could not record it. May be something was wrong, but i could't found the log or more message.

Additional context

i try to compare the trace file(context.tracing create), i found the route._continue count become less normal case: image base case: image

Environment

- Operating System: [linux]
- CPU: [arm64]
- Browser: [Chromium]
- Python Version: [3.10.6]
- Other info:
mxschmitt commented 1 month ago

This issue is not following the bug template. Please re-file and provide a self-contained reproduction, which we can run locally to reproduce your issue. Ideally a single file without any external dependencies. Thanks for your understanding!