Skip to content

[Bug]: Error running Playwright test in Windows runner in GitHub actions[Bug]: #2506

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
pamelafox opened this issue Aug 1, 2024 · 2 comments

Comments

@pamelafox
Copy link
Member

Version

1.45.1

Steps to reproduce

See the CI here:
https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/job/28188453780?pr=66

Here's the workflow file:
https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/workflow?pr=66

The playwright tests run fine in Mac, but they fail in the Windows runner.

We'll go ahead and disable them in main, but you can replicate by using our code at that point in time in a fork:
commit 0cf5e354b0e8e9723920887b769d8649730baa25 in https://github.com/john0isaac/rag-postgres-openai-python/tree/add-playwright-tests

Expected behavior

We expect tests to pass.

Actual behavior

We see this error:

____________________ ERROR at setup of test_home[chromium] ____________________

launch_browser = <function launch_browser.<locals>.launch at 0x0000016AF7510670>

    @pytest.fixture(scope="session")
    def browser(launch_browser: Callable[[], Browser]) -> Generator[Browser, None, None]:
>       browser = launch_browser()

C:\hostedtoolcache\windows\Python\3.10.11\x[64](https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/job/28188453780?pr=66#step:16:65)\lib\site-packages\pytest_playwright\pytest_playwright.py:2[66](https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/job/28188453780?pr=66#step:16:67): 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\pytest_playwright\pytest_playwright.py:258: in launch
    browser = browser_type.launch(**launch_options)
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\playwright\sync_api\_generated.py:14155: in launch
    self._sync(
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\playwright\_impl\_browser_type.py:94: in launch
    Browser, from_channel(await self._channel.send("launch", params))
C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\playwright\_impl\_connection.py:59: in send
    return await self._connection.wrap_api_call(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <playwright._impl._connection.Connection object at 0x0000016AF[72](https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/job/28188453780?pr=66#step:16:73)B8610>
cb = <function Channel.send.<locals>.<lambda> at 0x0000016AF[73](https://github.com/Azure-Samples/rag-postgres-openai-python/actions/runs/10189786904/job/28188453780?pr=66#step:16:74)8E8C0>
is_internal = False

    async def wrap_api_call(
        self, cb: Callable[[], Any], is_internal: bool = False
    ) -> Any:
        if self._api_zone.get():
            return await cb()
        task = asyncio.current_task(self._loop)
        st: List[inspect.FrameInfo] = getattr(task, "__pw_stack__", inspect.stack())
        parsed_st = _extract_stack_trace_information_from_stack(st, is_internal)
        self._api_zone.set(parsed_st)
        try:
            return await cb()
        except Exception as error:
>           raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
E           playwright._impl._errors.Error: BrowserType.launch: ENOENT: no such file or directory, mkdtemp 'undefined\temp\playwright-artifacts-XXXXXXXXXXXX'

C:\hostedtoolcache\windows\Python\3.10.11\x64\lib\site-packages\playwright\_impl\_connection.py:514: Error

Additional context

No response

Environment

- Operating System: Windows
- CPU: Whatever is used by GitHub windows runner
- Browser: Chromium
- Python Version: 3.10 - 3.12
- Other info:
@mxschmitt
Copy link
Member

This looks suspicious: https://github.com/Azure-Samples/rag-postgres-openai-python/blob/0cf5e354b0e8e9723920887b769d8649730baa25/tests/conftest.py#L46

Try to remove clear or just write to os.environ. Playwright needs good environment variables, and you fully clear them probably.

@pamelafox
Copy link
Member Author

Ah, interesting- I often use clear=True so that we don't have to overspecify every single environment variable, and can rely on unset env variables taking on their default values in configuration. I don't think it's an issue in this repo, but it was an issue in another repo.
Anyways, I just did a test CI removing clear=True for this repo, and all passed!
I can make sure to only clear the app's env variables in future to avoid trampling on playwright vars. Thank you!

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

2 participants