需要C#来破解Selenium的第一次机会异常

本文关键字:第一次 机会 异常 Selenium 破解 需要 | 更新日期: 2023-09-27 18:21:15

我正在通过Visual Studio调试Selenium测试套件。我希望抛出/捕获的异常能够中断,这样我就可以找出缺少的内容,但我是C#/Visual Studio的新手,不知道该选择什么。

一个示例异常块:

The thread '<No Name>' (0x75ac) has exited with code 0 (0x0).
A first chance exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll
A first chance exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in Selenium.WebDriverBackedSelenium.dll
A first chance exception of type 'Selenium.SeleniumException' occurred in Selenium.WebDriverBackedSelenium.dll
The thread '<No Name>' (0x7250) has exited with code 0 (0x0).

我该选择什么让它在第一次出现异常时停止,这样我就可以修复代码了?

谢谢!

需要C#来破解Selenium的第一次机会异常

如果选择DEBUG->Exceptions,将出现一个窗口,其中包含异常类型列表和2列,Thrown和User unhandled。确保为"公共语言运行时异常"选择了"抛出"列(如果Selenium是clr)。这将导致调试器中断使用try/catch管理的异常。

编辑

您可能还需要选择调试->选项和设置,并在调试->常规中取消选择"仅启用我的代码"。不过要小心,这将导致.NET框架源代码的符号被立即下载,或者在下次开始调试时下载。