[英]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可能会在该方法中遇到(已处理的)异常,这就是为什么您在正常运行期间看不到它的原因。
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.