任何人都可以帮我解决这个链接问题:

时间:2013-11-15 08:16:01

标签: selenium selenium-rc

我正在编写用于点击链接的代码:

<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 Snippet就是

<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)

任何人都可以建议我为什么我无法点击链接?

1 个答案:

答案 0 :(得分:0)

  1. 确保Selenium是您的对象,而不是selenium
  2. 我的猜测是你的问题是间距。
  3. selenium.click("link = Sign in as different user")更改为...

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

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