Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 含硒容器试验#_C#_Json_Selenium - Fatal编程技术网

C# 含硒容器试验#

C# 含硒容器试验#,c#,json,selenium,C#,Json,Selenium,如果元素不存在,我如何在c#中继续硒测试 如果selenium元素不在页面上,我想跳过它。当没有元素时,可以使用异常处理来避免测试失败 try { webDriver.FindElement(By.Id(id)); } catch(NoSuchElementException) { } 或者使用数组,因为查找多个元素不会导致异常,所以只需空数组即可 IWebElement[] elements = webDriver.FindElements(By.Id(id)).ToArray();

如果元素不存在,我如何在c#中继续硒测试


如果selenium元素不在页面上,我想跳过它。

当没有元素时,可以使用异常处理来避免测试失败

try
{
    webDriver.FindElement(By.Id(id));
}
catch(NoSuchElementException)
{
}
或者使用数组,因为查找多个元素不会导致异常,所以只需空数组即可

IWebElement[] elements = webDriver.FindElements(By.Id(id)).ToArray();
if (elements.Count() != 0)
{
    do what you want
}

当没有元素时,您可以使用异常处理来避免测试失败

try
{
    webDriver.FindElement(By.Id(id));
}
catch(NoSuchElementException)
{
}
或者使用数组,因为查找多个元素不会导致异常,所以只需空数组即可

IWebElement[] elements = webDriver.FindElements(By.Id(id)).ToArray();
if (elements.Count() != 0)
{
    do what you want
}

我想跳过一个不存在的项目并且不停止测试seleniumWell。。。就是这样。我想跳过一个不存在的项目,不停止测试seleniumWell。。。它做到了。