如何使用selenium c#将Kendo下拉值存储在变量中

时间:2017-09-14 13:27:42

标签: c# selenium-webdriver kendo-ui automation

//workflow
if (((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].click();", driver.FindElement(By.XPath("//*[@id='chk_user_1']"))) != null)
{
    File.AppendAllText(@"D:\TestingScript\Search Package\UnitTestProject1\Logs\TestDPS.txt", "TestCase 3 is running successfully with Network" + Environment.NewLine);
}

else
{
    File.AppendAllText(@"D:\TestingScript\Search Package\UnitTestProject1\Logs\TestDPS.txt", "TestCase 3 is running unsuccessfully with Network" + Environment.NewLine);
}

以上代码对我不起作用。请帮帮我!

在日志文件中,它始终显示结果数据,如下所示

  

“TestCase 3在网络上运行失败”。

1 个答案:

答案 0 :(得分:0)

IList<IWebElement> all = driver.FindElements(By.id("chk_user_1"));
int size = all.size();

if (size != 0)
{
    File.AppendAllText(@"D:\TestingScript\Search Package\UnitTestProject1\Logs\TestDPS.txt", "TestCase 3 is running successfully with Network" + Environment.NewLine);
}

else
{
    File.AppendAllText(@"D:\TestingScript\Search Package\UnitTestProject1\Logs\TestDPS.txt", "TestCase 3 is running unsuccessfully with Network" + Environment.NewLine);
}