1

我正在编写用于单击链接的代码,如下所示:

<a style="left: 520px; top: 340px; height: 24px; color: blue; position: absolute;" href="Login.aspx?iUserFlag=1">

文本:以其他用户身份登录?

我写成:

Selenium.click(“link = Sign in as different user?”);

但是我无法点击,有人可以帮忙吗?

用于此的 HTML 片段是

<A style="POSITION: absolute; HEIGHT: 24px; COLOR: blue; TOP: 340px; LEFT: 520px" href="http://kaizenblitz/Login.aspx?iUserFlag=1">Sign in as different user?</A>

我在执行时收到的错误消息是:

Exception in thread "main" com.thoughtworks.selenium.SeleniumException: ERROR: Element link = Sign in as different user? not found
at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:109)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:103)
at com.thoughtworks.selenium.DefaultSelenium.click(DefaultSelenium.java:193)
at seleniumproject.gmail.main(gmail.java:19)

谁能告诉我为什么我无法点击链接?

4

1 回答 1

0
  1. 确保这Selenium是您的对象,而不是selenium.
  2. 我的猜测是你的问题是间距。

改为selenium.click("link = Sign in as different user")...

selenium.click("link=Sign in as different user")

您的测试正在寻找包含文本的链接" Sign in as different user"(注意开头的空格)

于 2013-11-15T15:58:27.743 回答