Watir - 使用时获取Watir :: Heading(TypeError):选择器之后

时间:2013-03-22 04:20:04

标签: ruby watir functional-testing

我正在尝试获取无序列表中的特定链接。 ul元素位于h2标题下面的页面上,文本为“Application help”

我有一个watir步骤:

  app_help_header = @browser.h2(:text => "Application help")

  assert @browser.link(:after? => app_help_header, :text => link_text ).exists?

我在第二行收到此错误:

# features/step_definitions/steps_86_application_help.rb:73
expected one of [String, Regexp], got #<Watir::Heading:0x50d30c54 located=
false selector={:text=>"Application help", :tag_name=>"h2"}>:Watir::Heading (Typ
eError)
./features/step_definitions/steps_86_application_help.rb:88:in `/^I click
on "(.*?)" in Application Help$/'
features\86_Application_Help.feature:22:in `And I click on "Ordering" in A
pplication Help'

有谁知道为什么会这样?对于可用于:after属性的选择器的类型有什么限制吗?

使用:after作为选择器时,http://wiki.openqa.org/display/WTR/HTML+Elements+Supported+by+Watir处的文档未提及任何限制。

我正在尝试获取链接的HTML是:

<div class="application-help-summary module">
<h2 class="portlet-section-header">Application help</h2>
    <div class="portlet-section-body">
        <p>Browse help for assistance with: </p>
        <ul class="bulleted">
                    <li>
                        <a href="/ordering-help">Ordering</a>
                    </li>
                    <li>
                        <a href="/managing-services-help">Managing services</a>
                    </li>
        </ul>

    </div>
</div>

我正在尝试指定Watir:“通过”应用程序帮助“获取h2之后发生的文本链接

作为一种解决方法,我刚刚指定了更高级别的div,然后直接获取链接,指定代码假设“应用程序帮助”h2上方没有带有相同文本的链接。

0 个答案:

没有答案