为了调查某些Selenium测试失败,我想在运行测试时自动启用Chrome Devtools中的异常暂停功能。
有一个--auto-open-devtools-for-tabs用于自动打开我已经在使用的DevTools窗格的命令行选项,但是显然我没有要使用的自动暂停功能的CLI选项/参数。
我遇到的是我尝试使用激活的Debugger.setPauseOnExceptionsChrome Devtools Protocol命令execute_cdp_cmd(我正在将Selenium用于Python):
driver.execute_cdp_cmd("Debugger.setPauseOnExceptions", {"state": "all"})
Run Code Online (Sandbox Code Playgroud)
不幸的是,即使打开了选项卡(包括DevTools窗格),我也得到了
unhandled inspector error: {"code":-32000,"message":"Debugger agent is not enabled"}
Run Code Online (Sandbox Code Playgroud)
我在做什么错或者还有其他方法(最好是可靠且可移植的方法,请不要使用任何宏东西)?
python selenium google-chrome-devtools selenium-chromedriver selenium-webdriver