简体   繁体   English

仅在Visual Studio 2015的调试模式下引发WebDriverWait异常

[英]WebDriverWait Exception only thrown in Debug Mode in Visual Studio 2015

I was wondering if anyone else has encountered a similar problem like this or has experiences using WebDriverWait? 我想知道是否还有其他人遇到过类似的问题或有使用WebDriverWait的经验?

If they would know why I get a NoSuchElementException which seems to only be thrown in debug mode . 如果他们知道为什么我会收到一个NoSuchElementException,它似乎只在调试模式下抛出 I don't get this error being thrown when running the test in normal runtime. 在正常运行时运行测试时,我不会抛出此错误。

I am able to click continue and step past the exception also. 我可以单击继续,也可以跳过异常。

在此处输入图片说明

I believe this is a quirk of Visual Studio's debug mode. 我相信这是Visual Studio调试模式的怪癖。 Essentially in debug mode exceptions are sometimes treated as a break even if it is appropriately handled within a try/catch. 本质上,在调试模式下,即使在try / catch中适当地处理了异常,有时也会将其视为中断。

Remember when you pass a func to Until() in WebDriver, that func is executed internally within a try. 请记住,当您将功能传递给WebDriver中的直到()时,该功能将在一次尝试中在内部执行。 VS is likely hitting the (handled) exception in that method, which is why you do not see it during normal running. VS可能会在该方法中遇到(已处理的)异常,这就是为什么您在正常运行期间看不到它的原因。

See here for more info. 有关更多信息,请参见此处

Here is a workaround, for example if you are trying to find an element: 这是一种解决方法,例如,如果您尝试查找元素:

wait.Until(driver => driver.FindElement(
    By.CssSelector(".cssClass"))
);

You can do this: 你可以这样做:

wait.Until(driver => driver.FindElements(
    By.CssSelector(".cssClass")).FirstOrDefault()
);

And it will work on both release and debug environments. 它将在发布和调试环境中都可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 仅限调试中的Visual Studio 2015 UnauthorizedAccessException - Visual Studio 2015 UnauthorizedAccessException in Debug Only 在调试模式下引发异常,但是在哪里? - Exception thrown in debug mode, but where? Visual Studio 2015调试错误“无法执行,一般异常” - visual studio 2015 debug error “unable to step, general exception” 在更新Visual Studio 2015 Update 1后尝试访问Entity DB时引发异常 - Exception thrown when trying to access Entity DB, after updating visual studio 2015 update 1 Selenium ChromeDriver (C#) 仅在 Visual Studio 调试模式下崩溃 - Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode 在调试模式下如何查看Visual Studio(2015/2013)中的基础类型 - How to see the underlying type in Visual Studio (2015/2013) when in debug mode Visual Studio 2015:我无法在发布模式下调试和使用断点 - Visual Studio 2015: I can't debug and use breakpoints in Release mode Visual Studio 2015无法调试xamarin项目 - Visual studio 2015 cannot debug xamarin project Visual Studio 2015 项目无法调试 - Visual studio 2015 project doesn't debug Visual Studio 2015,Resharper冻结调试UnitTests - Visual Studio 2015, Resharper freezing on debug UnitTests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM