Watir webdriver,使用Firefox点击链接给出错误 - UnknownError:l未定义,而在chrome中工作正常

时间:2012-09-21 05:16:26

标签: watir-webdriver

我有一个网页(https://)在这个页面,每当我试图点击任何链接时,它给我一个奇怪的错误。当我使用firefox浏览器自动化时,这给了我错误。 如果我使用chrome,则会点击任何链接而不会出现任何错误。

HTML就像这样:

<li id="tab2" class=""><a role="button" aria-pressed="false" id="tab2link" onfocus="onFocusLink(&quot;tab2link&quot;)" onblur="onBlurLink(&quot;tab2link&quot;)" href="/workplace/myportal/!ut/p/c5/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hLAyAwNTAwsvAKM‌​jbw9HQJdXYLCTU2CDYAykeaxRvgAI4GIN1OIGYASHeYM1C3ob-_ZaCfr4GBvxFENx55_HaHg1xrFu_nbx‌​TqZuJpaGhh5mpoYGTmYeLkE-Zp4O5iDJHH4zo_j_zcVP2C3NAIgywTRQDl3__u/?uri=nm:oid:6_B0000‌​P002GVC30IMJ4J6J400U3" style="outline: none; ">MyLink</a></li>

我得到的错误如下:

Selenium::WebDriver::Error::UnknownError: l is undefined
        from [remote server] file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/webdrive r-profile20120921-5620-dorvjl/extensions/fxdriver@googlecode.com/components/comm and_processor.js:9497:in `unknown'
        from [remote server] file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/webdrive r-profile20120921-5620-dorvjl/extensions/fxdriver@googlecode.com/components/comm and_processor.js:10131:in `unknown'
        from [remote server] file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/webdrive r-profile20120921-5620-dorvjl/extensions/fxdriver@googlecode.com/components/comm and_processor.js:10136:in `unknown'
        from [remote server] file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/webdrive r-profile20120921-5620-dorvjl/extensions/fxdriver@googlecode.com/components/comm and_processor.js:10074:in `unknown'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/response.rb:52:in `assert_ok'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/response.rb:15:in `initialize'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/http/common.rb:59:in `new'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/http/common.rb:59:in `create_response'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/http/default.rb:65:in `request'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/http/common.rb:40:in `call'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/bridge.rb:598:in `raw_execute'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/bridge.rb:576:in `execute'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/remote/bridge.rb:358:in `clickElement'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/s elenium/webdriver/common/element.rb:54:in `click'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/elements/element.rb:108:in `click'
        from (irb):6
        from C:/Ruby192/bin/irb:12:in `<main>'irb(main):007:0>

任何人都可以帮助我,因为这完全不在我的脑海里。

我正在使用的Watir代码是一个简单的链接,按其文字

点击代码
browser.link(:text, "MyLink").click

此外,如果我在click方法中传递任何参数,例如:shift或:control,它正在工作,它点击链接但不是没有参数,它发生在firefox中使用watir-webdriver

1 个答案:

答案 0 :(得分:0)

由于你的html显示了一个锚元素,所以请尝试这个(我有类似的问题并且这样做可以解决):

browser.a(:text, 'MyLink').click