Selenium _webDriver 未通过 By.LinkText 找到元素
Selenium _webDriver not finding element through By.LinkText
我正在 运行 使用 Selenium webdriver 进行一些验收测试 (C#),并且有以下代码行:
var link = _webDriver.FindElement(By.LinkText("Manage Service"));
link.Click();
在导航页面上,这个锚是我要定位的:
<a onclick="doEdit(this, 73332)" href="javascript:void(0);">
<span>Manage Service</span>
</a>
但是由于 Selenium 无法找到该锚标记,测试失败了。我的印象是 Selenium 能够处理上述情况。
我也试过 By.PartialLinkText()
但还是找不到!
为什么找不到 link?
找不到它的原因是因为上一步没有正常工作。
这是我的测试结果:
When I navigate to the 'services' page for the 'organisation'
And I log into the site as a OD editor and return to the page I was on
And I click on the 'Manage Service' link
没有给登录站点步骤足够的时间。所以我告诉它等待 2 秒,然后进入下一步。
Thens.WaitForSecond(2);
现在它找到了,没有任何问题。
谢谢
我正在 运行 使用 Selenium webdriver 进行一些验收测试 (C#),并且有以下代码行:
var link = _webDriver.FindElement(By.LinkText("Manage Service"));
link.Click();
在导航页面上,这个锚是我要定位的:
<a onclick="doEdit(this, 73332)" href="javascript:void(0);">
<span>Manage Service</span>
</a>
但是由于 Selenium 无法找到该锚标记,测试失败了。我的印象是 Selenium 能够处理上述情况。
我也试过 By.PartialLinkText()
但还是找不到!
为什么找不到 link?
找不到它的原因是因为上一步没有正常工作。
这是我的测试结果:
When I navigate to the 'services' page for the 'organisation'
And I log into the site as a OD editor and return to the page I was on
And I click on the 'Manage Service' link
没有给登录站点步骤足够的时间。所以我告诉它等待 2 秒,然后进入下一步。
Thens.WaitForSecond(2);
现在它找到了,没有任何问题。
谢谢