[英]try catch block with if condition is not working in selenium webdriver C#
if
condition within try
block does not work. if
try
块中的条件不起作用。
Script execution is always going out of the try catch
loop even if the element (defined with Xpath) is present/displayed in the Web page. 即使Web页面中存在/显示了元素(用Xpath定义),脚本执行也总是脱离
try catch
循环。 if
condition fails. if
条件失败。
Any help will be appreciated. 任何帮助将不胜感激。
try
{
string path = "//*@id='form_780_0']/div[2]/div/div[3]/div";
if(driver.FindElement(By.XPath(path)).Displayed)
{
Assert.Fail("Fails");
}
}
catch (Exception)
{
//There is nothing here
}
// Some code here and this is executed after evaluating if condition
// even if element is displayed
"Execution does not go into exception path either. it goes out of try catch loop after evaluating if condition" “执行也不会进入异常路径。它在评估是否满足条件后会退出try catch循环”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.