0

每当我尝试单击任何链接时,我都会在此页面中有一个网页(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,它正在工作,它正在单击链接但不是没有参数,它正在使用 watir-webdriver 在 Firefox 中发生

4

1 回答 1

0

由于您的 html 显示了一个锚元素,请改为尝试此操作(我遇到了类似的问题并这样做是为了解决问题):

browser.a(:text, 'MyLink').click
于 2012-09-21T18:11:47.810 回答