【发布时间】:2018-06-19 05:25:45
【问题描述】:
我正在尝试检查页面上的文本,当我检查它时,我看到:
< div class="welcome-message">
< h1 data-bind="text: $.t('wfo.Common:wfo.Welcome'), attr: { title: $.t('wfo.Common:wfo.Welcome') }" title="Welcome">Welcome</h1>
在我的代码中,我使用 Xpath 来查找元素,然后尝试验证这一点
Assert.IsTrue(AdminPage.IsAt, "Not In Admin Page");
通过实现以下代码:
public static bool IsAt {
get{
var h3 = Driver.instance.FindElements(By.XPath("//div[@class='welcome-message']/h1[@title='Welcome']"));
if (h3.Count >0)
return true;
return false;
}
}
但是当我运行该案例时,我遇到了失败:看到“不在管理页面”错误消息。
我要做的是根据搜索条件返回一个 IwebElements 列表,当找到该元素时应该返回一个真实的响应,直到现在,我假设我想匹配“真”条件.我是 Selenium 的新手,非常感谢您的帮助,非常感谢。
【问题讨论】:
-
你有 HTML 吗?
标签: c# selenium xpath selenium-chromedriver