在watir中搜索带下划线的链接

问题描述

|| 我正在尝试搜索/选择带下划线的页面中的链接,而其他链接则没有。来源是这样的:
<a href=\"someurl1\">
<b>
<u>Some ulined text</u>
</b>
<u></u>
</a>
<br>
<a href=\"someurl2\">Other link text</a>
<br>
<a href=\"someurl3\">Another Link text</a>
<br>
我尝试了类似的东西
link = browser.link(:u?,true)
link.exists?
我收到以下错误
TypeError: expected one of [String,Regexp],got true:TrueClass
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:152:in `check_type\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:189:in `normalized_selector\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:188:in `each\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:188:in `normalized_selector\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:76:in `find_first_by_multiple\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:33:in `locate\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:260:in `locate\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:247:in `assert_exists\'
    from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:31:in `exist?\'
编辑: 因此,我实际上是将其用于屏幕抓取而不是测试。这可能解释了为什么watir不直接支持此功能的原因,因为CSS和其他更好的做法对于测试有意义,并且在HTML开发和测试同时进行时。从抓取的角度来看,服务器是用户看到的文本格式,搜索带下划线的粗体链接等对于抓取是有意义的。     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)