Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悰 Bug]: When starting chromedriver with add_argument(f"--load-extension={extension_load}") - BIDI connection make Page.* commands unavailable #13759

Open
HermesNWO opened this issue Mar 28, 2024 · 7 comments

Comments

@HermesNWO
Copy link

What happened?

When starting chromedriver with the load-extension argument, BiDi connection won't makes the Page.* commands available/working.

Below easy step to reproduce

How can we reproduce the issue?

... driver loads
driver_options.add_argument(f"--load-extension={extension_load}")
... driver start no headless

async with self.driver.bidi_connection() as connection:
    self.cdp_bidi_main_session, self.cdp_bidi_main_devtools, self.cdp_cdp = connection.session, connection.devtools, connection.cdp
    await self.cdp_bidi_main_session.execute(self.cdp_bidi_main_devtools.page.enable())

Relevant log output

DEBUG:POST http://localhost:34881/session {'capabilities': {'firstMatch': [{}], 'alwaysMatch': {'browserName': 'chrome', 'pageLoadStrategy': <PageLoadStrategy.normal: 'normal'>, 'goog:chromeOptions': {'prefs': {'credentials_enable_service': False, 'profile.password_manager_enabled': False, 'webrtc.ip_handling_policy': 'disable_non_proxied_udp', 'webrtc.multiple_routes_enabled': False, 'webrtc.nonproxied_udp_enabled': False, 'intl.accept_languages': 'fr-FR', 'intl.timezone': 'Europe/Paris'}, 'excludeSwitches': ['enable-automation'], 'extensions': [], 'args': ['--proxy-server=socks5://127.0.0.1:35001', '--enable-logging=true', '--log-level=3', '--no-sandbox', '--ignore-certificate-errors', '--disable-popup-blocking', '--blink-settings=imagesEnabled=true', '--window-position=0,0', '--window-size=1920,1080', '--remote-debugging-port=9222', '--remote-allow-origins=http://localhost:9222', '--load-extension=/home/bb/Documents/$$$/addons/I-still-don-t-care-about-cookies']}}}}
DEBUG:Remote response: status=200 | data={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"123.0.6312.86","chrome":{"chromedriverVersion":"123.0.6312.86 (9b72c47a053648d405376c5cf07999ed626728da-refs/branch-heads/6312@{#698})","userDataDir":"/tmp/.org.chromium.Chromium.i2pRuK"},"fedcm:accounts":true,"goog:chromeOptions":{"debuggerAddress":"localhost:9222"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"linux","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:extension:minPinLength":true,"webauthn:extension:prf":true,"webauthn:virtualAuthenticators":true},"sessionId":"99448360b81ee3f8688cb4f00b1f6e9a"}} | headers=HTTPHeaderDict({'Content-Length': '846', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
DEBUG:POST http://localhost:34881/session/99448360b81ee3f8688cb4f00b1f6e9a/goog/cdp/execute {'cmd': 'Emulation.setGeolocationOverride', 'params': {'latitude': 48.8582, 'longitude': 2.3387, 'accuracy': 1000}}
DEBUG:Remote response: status=200 | data={"value":{}} | headers=HTTPHeaderDict({'Content-Length': '12', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
DEBUG:POST http://localhost:34881/session/99448360b81ee3f8688cb4f00b1f6e9a/goog/cdp/execute {'cmd': 'Emulation.setLocaleOverride', 'params': {'locale': 'fr-FR'}}
DEBUG:Remote response: status=200 | data={"value":{}} | headers=HTTPHeaderDict({'Content-Length': '12', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
DEBUG:POST http://localhost:34881/session/99448360b81ee3f8688cb4f00b1f6e9a/goog/cdp/execute {'cmd': 'Emulation.setTimezoneOverride', 'params': {'timezoneId': 'Europe/Paris'}}
DEBUG:Remote response: status=200 | data={"value":{}} | headers=HTTPHeaderDict({'Content-Length': '12', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
DEBUG:POST http://localhost:34881/session/99448360b81ee3f8688cb4f00b1f6e9a/goog/cdp/execute {'cmd': 'Page.getFrameTree', 'params': {}}
DEBUG:Remote response: status=200 | data={"value":{"frameTree":{"frame":{"adFrameStatus":{"adFrameType":"none"},"crossOriginIsolatedContextType":"NotIsolated","domainAndRegistry":"","gatedAPIFeatures":[],"id":"3E4BA21EACF4205817657C425061EAEB","loaderId":"B55C2BD04DC8AEBCECC275E95F26F952","mimeType":"text/plain","secureContextType":"InsecureScheme","securityOrigin":"://","url":"data:,"}}}} | headers=HTTPHeaderDict({'Content-Length': '351', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
DEBUG:POST http://localhost:34881/session/99448360b81ee3f8688cb4f00b1f6e9a/goog/cdp/execute {'cmd': 'Page.getFrameTree', 'params': {}}
DEBUG:Remote response: status=200 | data={"value":{"frameTree":{"frame":{"adFrameStatus":{"adFrameType":"none"},"crossOriginIsolatedContextType":"NotIsolated","domainAndRegistry":"","gatedAPIFeatures":[],"id":"3E4BA21EACF4205817657C425061EAEB","loaderId":"B55C2BD04DC8AEBCECC275E95F26F952","mimeType":"text/plain","secureContextType":"InsecureScheme","securityOrigin":"://","url":"data:,"}}}} | headers=HTTPHeaderDict({'Content-Length': '351', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})
DEBUG:Finished Request
Exception in thread Thread-2 (__capture_targets_creation):
Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/home/bb/Documents/$$$/modules/driver_emulation_injector.py", line 159, in __capture_targets_creation
    trio.run(self.__capture_targets_creation_bidi)
  File "/home/bb/.local/lib/python3.11/site-packages/trio/_core/_run.py", line 2262, in run
    raise runner.main_task_outcome.error
  File "/home/bb/Documents/$$$/modules/driver_emulation_injector.py", line 276, in __capture_targets_creation_bidi
    await self.cdp_bidi_main_session.execute(self.cdp_bidi_main_devtools.page.enable())
  File "/home/bb/.local/lib/python3.11/site-packages/selenium/webdriver/common/bidi/cdp.py", line 226, in execute
    raise response
selenium.webdriver.common.bidi.cdp.BrowserError: BrowserError<code=-32601 message='Page.enable' wasn't found> None

Operating System

Linux

Selenium version

4.19.0

What are the browser(s) and version(s) where you see this issue?

Chromedriver 123 - 122

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver 123 - 122

Are you using Selenium Grid?

No response

Copy link

@HermesNWO, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@HermesNWO HermesNWO changed the title [馃悰 Bug]: When starting chromedriver with add_argument(f"--load-extension={extension_load}") - BIDI connection make Page.* commands [馃悰 Bug]: When starting chromedriver with add_argument(f"--load-extension={extension_load}") - BIDI connection make Page.* commands unavailable Mar 28, 2024
@diemol
Copy link
Member

diemol commented Mar 29, 2024

Was this working before, or are you trying this for the first time? I believe our BiDi support in Python needs work.

@AutomatedTester do you know if this should be working?

@HermesNWO
Copy link
Author

HermesNWO commented Mar 29, 2024

I have also tried with Selenium 4.16.0 and Chromedriver 122 and then updated to see if any chance of work but nothing...
And this is the first time I implement BIDI for Target.* related, and it doesn't work... For others like Network.* it also doesn't work and don't start.

@HermesNWO
Copy link
Author

Actually with my different tries, it happen only with this extension : https://chromewebstore.google.com/detail/i-still-dont-care-about-c/edibdbjcniadpccecjdfdjjppcpchdlm, for the others it works.

@diemol
Copy link
Member

diemol commented Apr 1, 2024

It seems to be an issue with the extension, as mentioned in the extension reviews.

I will close this as the root cause is outside Selenium.

@diemol diemol closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
@HermesNWO
Copy link
Author

No this is a real issue, for example it also stop working with this extensions : https://chromewebstore.google.com/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi

@HermesNWO
Copy link
Author

Okay I have found the solution : after reading cdps logs, we can see that the initial BiDi session is using the first target found in the list to make a general session. Indeed we don't want to attach to the first but the last element of the list :

Modify async def bidi_connection(self): in webdriver.py and use -1 instead of 0

@diemol diemol reopened this Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants