0

请原谅初学者的问题,但我希望在谷歌搜索一段时间后我能在这里得到一些实际的帮助。

我在 C# Express 2010 中执行以下操作:

selenium.Click("link=Specimen Volume Report - Drugs");

我试图点击的 html 源代码是:

<a href="/Admin/Reports/SpecimenVolume.aspx?p=lKpZwTqT4/OMY6523drWvbTjKKs7Nu4Z">Specimen Volume Report - Drugs&nbsp;</a>

我得到的错误是:

LogIn.LogIn.Login:
Selenium.SeleniumException : ERROR: Element link=Specimen Volume Report - Drugs not found

我究竟做错了什么?您需要我提供哪些信息来提供帮助?

4

2 回答 2

1

假设selenium是我认为你想要的网络驱动程序:

selenium.FindElement(By.LinkText("Specimen Volume Report - Drugs&nbsp;")).Click();

By.PartialLinkText("Report - Drugs")如果您喜欢这个想法,您可以使用 too 来缩短字符串。

我建议查看http://seleniumhq.org/docs/03_webdriver.html上的文档,特别是Locating UI Elements (WebElements)以查看查找元素的不同方式。

于 2012-07-21T00:03:14.867 回答
1

You are getting error may be because of space at end of Specimen Volume Report - Drugs&nbsp;
You can try to go with different element locator, below i have mentioned one of them,

selenium.click("//a[contains(text(),"Specimen Volume Report")]")
于 2012-07-21T05:29:31.473 回答