如何获取RUBY Capybara.Fail中的帮助标签文本获取文本帮助标签(默认值为180天,允许值范围为30-180)任何人帮助我

时间:2015-10-13 12:46:15

标签: ruby capybara

<label for='zip'>Password Duration – maximum days:</label>
<input Value="180" id="PasswordExpiryDays" name="PasswordExpiryDays" type="text"/>
<a class="links" id="PasswordAge_Tip" tabindex="-1" 
   onblur="HideLayer('PasswordAge')" 
   onmouseover="ShowLayer('PasswordAge')" 
   onmouseout="HideLayer('PasswordAge')" href="#">?</a>
<span id="PasswordAge" style="VISIBILITY: hidden;">     
    <table>
        <tr>      
           <td>
               Default value is 180 days and allowed value range is 30-180
           </td>
        </tr>
    </table>
</span>

无法获取文本帮助标记值(默认值为180天,允许值范围为30-180)任何人都可以帮助我。

2 个答案:

答案 0 :(得分:0)

该元素的可见性设置为隐藏&#39;。您是否将capybara配置为处理隐藏元素?

答案 1 :(得分:0)

重新格式化你的html以便它的可读性会有所帮助,并且xpath中失败的id是你的html中的跨度而不是输入

span = page.find(:xpath,"//span[@id='PasswordAge']/table/tr/td", visible: false) # page.find('#PasswordAge td', visible: false) would be easier to read
value = span.text(:all)  # The all is necessary to get non-visible text