In order to investigate some Selenium test failures I would like to automatically enable the pause on exception feature in the Chrome Devtools when running the tests.
There is the --auto-open-devtools-for-tabs
command line option for automatically opening the DevTools pane which I am already using but apparently there is no CLI option/parameter for the autopause feature I am looking for.
What I came across though is the Debugger.setPauseOnExceptions
Chrome Devtools Protocol command which I tried activating using execute_cdp_cmd
(I am using Selenium for Python):
driver.execute_cdp_cmd("Debugger.setPauseOnExceptions", {"state": "all"})
Unfortunately, even when the tab is open (including the DevTools pane) I am getting
unhandled inspector error: {"code":-32000,"message":"Debugger agent is not enabled"}
What am I doing wrong or is there some other way (preferably a reliable and portable way, please no macro stuff) I could use?
You probably need to enable the debugger before the command:
driver.execute_cdp_cmd("Debugger.enable", {})
driver.execute_cdp_cmd("Debugger.setPauseOnExceptions", {"state": "all"})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With