playwright: [REGRESSION]: selenium chrome instance hanging in a blank window
Context:
- GOOD Playwright Version: 1.17.2
- BAD Playwright Version: 1.19.1
- Operating System: MacOS 12.3
- Extra: Selenium Hub running in Docker, controlled with python
Code Snippet
pip3 install -U playwright==1.19.1
services:
selenium:
image: selenium/standalone-chrome:98.0
shm_size: 2gb
ports:
- 4444:4444
- 7900:7900
#!/usr/bin/env python3
from os import environ
from playwright.sync_api import sync_playwright
environ['SELENIUM_REMOTE_URL'] = 'http://127.0.0.1:4444/wd/hub'
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
page.goto("http://playwright.dev/", wait_until="networkidle")
input("Press [Enter] to close …")
browser.close()
(.venv) example> ./test.py
Traceback (most recent call last):
File "./test.py", line 10, in <module>
browser = p.chromium.launch(headless=False)
File "…/.venv/lib/python3.8/site-packages/playwright/sync_api/_generated.py", line 11417, in launch
self._sync(
File "…/.venv/lib/python3.8/site-packages/playwright/_impl/_sync_base.py", line 111, in _sync
return task.result()
File "…/.venv/lib/python3.8/site-packages/playwright/_impl/_browser_type.py", line 90, in launch
Browser, from_channel(await self._channel.send("launch", params))
File "…/.venv/lib/python3.8/site-packages/playwright/_impl/_connection.py", line 39, in send
return await self.inner_send(method, params, False)
File "…/.venv/lib/python3.8/site-packages/playwright/_impl/_connection.py", line 63, in inner_send
result = next(iter(done)).result()
playwright._impl._api_types.TimeoutError: Timeout 30000ms exceeded.
=========================== logs ===========================
<selenium> connecting to http://127.0.0.1:4444/wd/hub/
<selenium> connected to sessionId=7b2a065643032ca263f912372919fe8c
<selenium> using selenium v4
<selenium> retrieved endpoint ws://172.19.0.2:4444/session/7b2a065643032ca263f912372919fe8c/se/cdp for sessionId=7b2a065643032ca263f912372919fe8c
<ws connecting> ws://172.19.0.2:4444/session/7b2a065643032ca263f912372919fe8c/se/cdp
============================================================
example-selenium-1 | 19:16:05.155 INFO [LocalDistributor.newSession] - Session request received by the distributor:
example-selenium-1 | [Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-background-networ..., --enable-features=NetworkSe..., --disable-background-timer-..., --disable-backgrounding-occ..., --disable-breakpad, --disable-client-side-phish..., --disable-component-extensi..., --disable-default-apps, --disable-dev-shm-usage, --disable-extensions, --disable-features=Improved..., --allow-pre-commit-input, --disable-hang-monitor, --disable-ipc-flooding-prot..., --disable-popup-blocking, --disable-prompt-on-repost, --disable-renderer-backgrou..., --disable-sync, --force-color-profile=srgb, --metrics-recording-only, --no-first-run, --enable-automation, --password-store=basic, --use-mock-keychain, --no-service-autorun, --export-tagged-pdf, --enable-use-zoom-for-dsf=f..., --no-sandbox, --remote-debugging-port=0]}}]
example-selenium-1 | Starting ChromeDriver 98.0.4758.102 (273bf7ac8c909cde36982d27f66f3c70846a3718-refs/branch-heads/4758@{#1151}) on port 49837
example-selenium-1 | Only local connections are allowed.
example-selenium-1 | Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
example-selenium-1 | ChromeDriver was started successfully.
example-selenium-1 | [1647371765.176][SEVERE]: bind() failed: Cannot assign requested address (99)
example-selenium-1 | 19:16:05.948 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
example-selenium-1 | 19:16:05.959 INFO [LocalDistributor.newSession] - Session created by the distributor. Id: 7b2a065643032ca263f912372919fe8c, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 98.0.4758.102, chrome: {chromedriverVersion: 98.0.4758.102 (273bf7ac8c90..., userDataDir: /tmp/.com.google.Chrome.OTyH1c}, goog:chromeOptions: {debuggerAddress: localhost:39809}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://172.19.0.2:4444/sessio..., se:cdpVersion: 98.0.4758.102, se:vnc: ws://172.19.0.2:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.19.0.2:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
example-selenium-1 | 19:16:35.440 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local session map, Id: 7b2a065643032ca263f912372919fe8c
example-selenium-1 | 19:16:35.466 WARN [SpanWrappedHttpHandler.execute] - Unable to execute request: Cannot find session with id: 7b2a065643032ca263f912372919fe8c
example-selenium-1 | Build info: version: '4.1.2', revision: '9a5a329c5a'
example-selenium-1 | System info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'
example-selenium-1 | Driver info: driver.version: unknown
example-selenium-1 | org.openqa.selenium.NoSuchSessionException: Cannot find session with id: 7b2a065643032ca263f912372919fe8c
example-selenium-1 | Build info: version: '4.1.2', revision: '9a5a329c5a'
example-selenium-1 | System info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'
example-selenium-1 | Driver info: driver.version: unknown
example-selenium-1 | at org.openqa.selenium.grid.node.local.LocalNode.stop(LocalNode.java:444)
example-selenium-1 | at org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:395)
example-selenium-1 | at org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)
example-selenium-1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.grid.node.Node.execute(Node.java:240)
example-selenium-1 | at org.openqa.selenium.grid.web.CombinedHandler.execute(CombinedHandler.java:59)
example-selenium-1 | at org.openqa.selenium.grid.web.RoutableHttpClientFactory$1.execute(RoutableHttpClientFactory.java:72)
example-selenium-1 | at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)
example-selenium-1 | at org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:110)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.grid.router.Router.execute(Router.java:91)
example-selenium-1 | at org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)
example-selenium-1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)
example-selenium-1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68)
example-selenium-1 | at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)
example-selenium-1 | at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
example-selenium-1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
example-selenium-1 | at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)
example-selenium-1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)
example-selenium-1 | at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)
example-selenium-1 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
example-selenium-1 | at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
example-selenium-1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
example-selenium-1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
example-selenium-1 | at java.base/java.lang.Thread.run(Thread.java:829)
example-selenium-1 | 19:16:35.505 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "5268dde4c7a0b70f8eeac990b92d1381","eventTime": 1647371795465721639,"eventName": "exception","attributes": {"exception.message": "Unable to execute request: Cannot find session with id: 7b2a065643032ca263f912372919fe8c\nBuild info: version: '4.1.2', revision: '9a5a329c5a'\nSystem info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.NoSuchSessionException: Cannot find session with id: 7b2a065643032ca263f912372919fe8c\nBuild info: version: '4.1.2', revision: '9a5a329c5a'\nSystem info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.grid.node.local.LocalNode.stop(LocalNode.java:444)\n\tat org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:395)\n\tat org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.grid.web.CombinedHandler.execute(CombinedHandler.java:59)\n\tat org.openqa.selenium.grid.web.RoutableHttpClientFactory$1.execute(RoutableHttpClientFactory.java:72)\n\tat org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)\n\tat org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:110)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:91)\n\tat org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "org.openqa.selenium.NoSuchSessionException","http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "127.0.0.1:4444","http.method": "DELETE","http.scheme": "HTTP","http.target": "\u002fsession\u002f7b2a065643032ca263f912372919fe8c"}}
example-selenium-1 |
example-selenium-1 | 19:16:35.520 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "5268dde4c7a0b70f8eeac990b92d1381","eventTime": 1647371795518951091,"eventName": "exception","attributes": {"exception.message": "Unable to execute request for an existing session: Cannot find session with id: 7b2a065643032ca263f912372919fe8c\nBuild info: version: '4.1.2', revision: '9a5a329c5a'\nSystem info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.NoSuchSessionException: Cannot find session with id: 7b2a065643032ca263f912372919fe8c\nBuild info: version: '4.1.2', revision: '9a5a329c5a'\nSystem info: host: '1cf02b0e860c', ip: '172.19.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.104-linuxkit', java.version: '11.0.13'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.grid.node.local.LocalNode.stop(LocalNode.java:444)\n\tat org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:395)\n\tat org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.grid.web.CombinedHandler.execute(CombinedHandler.java:59)\n\tat org.openqa.selenium.grid.web.RoutableHttpClientFactory$1.execute(RoutableHttpClientFactory.java:72)\n\tat org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)\n\tat org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:110)\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.router.Router.execute(Router.java:91)\n\tat org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$NestedRoute.handle(Route.java:270)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n","exception.type": "org.openqa.selenium.NoSuchSessionException","http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.router.HandleSession","http.host": "127.0.0.1:4444","http.method": "DELETE","http.scheme": "HTTP","http.target": "\u002fsession\u002f7b2a065643032ca263f912372919fe8c","session.id": "7b2a065643032ca263f912372919fe8c"}}
example-selenium-1 |

Describe the bug
The selenium chrome instance is started, but hanging in a blank window instead of navigating to the url. The same example is working as expected in the older version (pip3 install -U playwright==1.17.2).
I’m not super experienced with neither playwright not selenium, so it might be, I’m using it wrong. But after it’s working with the older version, I judged it to be a regression.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 17 (1 by maintainers)
Hi! Same error here! It´s working until v1.17.
V 1.17 PW:browser* logs:
V 1.22.2 Logs:
Please let me know if you need me to do more tests.
Thanks!
I managed to work around the issue now, by setting the
SE_NODE_GRID_URLenvironment variable in the selenium container to the grid url (even though I’m using the standalone images) after reading https://github.com/microsoft/playwright/issues/11692#issuecomment-1176621857. Actually, I do not really understand why this environment variable fixes it and I still assume this needs to be fixed in the playwright codebase (or otherwise be explained in the help files).The fix in my
docker-compose.ymlabove, is like this:… alternatively, when running docker via command line, this is equivalent to
-e SE_NODE_GRID_URL=http://localhost:4444/.There is also the bug report https://github.com/SeleniumHQ/docker-selenium/issues/1451 to mention, which complains about this variable is missing.
I have same error, need this feature for speed time in CD!