[🐛 Bug]: devtools.debugger.enable() causes exception
See original GitHub issueWhat happened?
Trying to enable the Chrome DevTools debugger using the wrappers provided by Selenium will cause an exception. The enable()
functions for other CDP domains seem to work though (e.g., devtools.runtime.enable()
).
How can we reproduce the issue?
import trio
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
async def main():
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
async with driver.bidi_connection() as connection:
session, devtools = connection.session, connection.devtools
driver.get('https://google.com')
# Try to enable debugger
await session.execute(devtools.debugger.enable())
trio.run(main)
Relevant log output
Traceback (most recent call last):
File "bug.py", line 19, in <module>
trio.run(main)
File "/home/tim/.local/lib/python3.8/site-packages/trio/_core/_run.py", line 1946, in run
raise runner.main_task_outcome.error
File "bug.py", line 16, in main
await session.execute(devtools.debugger.enable())
File "/usr/lib/python3.8/contextlib.py", line 189, in __aexit__
await self.gen.athrow(typ, value, traceback)
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 1188, in bidi_connection
yield BidiConnection(session, cdp, devtools)
File "/usr/lib/python3.8/contextlib.py", line 189, in __aexit__
await self.gen.athrow(typ, value, traceback)
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/bidi/cdp.py", line 481, in open_cdp
await conn.aclose()
File "/home/tim/.local/lib/python3.8/site-packages/trio/_core/_run.py", line 813, in __aexit__
raise combined_error_from_nursery
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/bidi/cdp.py", line 458, in _reader_task
session._handle_data(data)
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/bidi/cdp.py", line 256, in _handle_data
self._handle_event(data)
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/bidi/cdp.py", line 293, in _handle_event
event = devtools.util.parse_json_event(data)
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/devtools/v102/util.py", line 19, in parse_json_event
return _event_parsers[json['method']].from_json(json['params'])
File "/home/tim/.local/lib/python3.8/site-packages/selenium/webdriver/common/devtools/v102/debugger.py", line 1219, in from_json
script_language=debugger.ScriptLanguage.from_json(json['scriptLanguage']) if 'scriptLanguage' in json else None,
NameError: name 'debugger' is not defined
Operating System
Linux Mint 20.1
Selenium version
Python 4.3.0
What are the browser(s) and version(s) where you see this issue?
Chrome 102.0.5005
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 102.0.5005.61
Are you using Selenium Grid?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Debugging in JavaScript: Pausing on Exceptions
In this lesson, we'll cover a new debugging tactic: pausing on exceptions. This involves configuring web browser DevTools to automatically ...
Read more >Showing JavaScript exception message in Chrome dev tools
Now on to my question: when I tell Chrome to 'pause on uncaught exceptions', it still correctly highlights the offending line in my...
Read more >DevTools: "pause on exception" still pause even if the Promise ...
Here an example with a simple try/catch, where the debugger will not pause because the error is catched. function Human(name) { this.name =...
Read more >10. Debugging and Error Handling - JavaScript Cookbook ...
When the code that could result in an error is contained in a try statement, the associated catch statement handles the exception it...
Read more >Debug JavaScript - Chrome Developers
Learn how to use Chrome DevTools to find and fix JavaScript bugs. ... for debugging a problem like this is to insert a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for the report @TimRecktenwald I have a small patch but the upstream generator is likely also broken which I will look to submit a patch too; should be usable when we ship a fix
Yes, the error persists with version 103 of Chrome and ChromeDriver.