Rayrun
← Back to Discord Forum

Playwright Threads Issue

So I've read that playwright isnt thread safe. However ive seen playwright working with the threading library so im a little confused. I am trying to run one browser with 2 different pages. I initialize the browser and 2 pages and then call the pages in a different file in a different method.

when I do:

await page.goto("https://google.com/")

I get

t\_impl\_connection.py", line 314, in _send_message_to_server
    raise Error(self._closed_error_message)
playwright._impl._api_types.Error: Connection closed

Is there anyway I can fix this so I can use 2 pages together. Isnt that what async is?

Sorry if that sounds condescending in any way, I learned that async is parallel so just a bit confused :).

Thanks for the help!

image.png

This thread is trying to answer question "How can I fix the 'Connection closed' error in Playwright and use two pages together?"

1 reply

init_playwright method is ran on import, and the variables are globalized. And the get_page method is called in other files / functions

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].