question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[🐛 Bug]: devtools.debugger.enable() causes exception

See original GitHub issue

What 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:open
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
symonkcommented, Jun 26, 2022

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

1reaction
TimRecktenwaldcommented, Jun 24, 2022

Yes, the error persists with version 103 of Chrome and ChromeDriver.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found