在Watir-Classic中寻找元素总是返回false

时间:2012-10-18 20:50:17

标签: html ruby watir watir-webdriver

<div class="wizardPanel box cf" id="wizardPanel">
    <p class="validation-msg error visually-hidden" id="error0"><span data-icon="warn"></span>Your departure and arrival cites must be different. Please correct the highlighted fields below.</p>
    <p class="validation-msg error visually-hidden" id="error1"><span data-icon="warn"></span>The return date must be later than the departure date. Please select a different date.</p>
    <p class="validation-msg error visually-hidden" id="error2"><span data-icon="warn"></span>Sorry, we're able to book only 1 to 6 passengers total per itinerary.</p>
    <p class="validation-msg error visually-hidden" id="error3"><span data-icon="warn"></span>Please select the ages of the children traveling.</p>
    <p class="validation-msg error visually-hidden" id="error4"><span data-icon="warn"></span>We are only able to book one infant in lap per traveler aged 12+.</p>
    <p class="validation-msg error visually-hidden" id="error5"><span data-icon="warn"></span>Children must not be allowed to travel without either a Senior or Adult.</p>
    <p class="validation-msg error visually-hidden" id="error6"><span data-icon="warn"></span>Please check the date highlighted below. Date format should be mm/dd/yy.</p>
    <p class="validation-msg error visually-hidden" id="error7"><span data-icon="warn"></span>Departure airport field is empty. Please enter correct airport name.</p>
    <p class="validation-msg error visually-hidden" id="error8"><span data-icon="warn"></span>Arrival airport field is empty. Please enter correct airport name.</p>
</div>

在上面的HTML标记中,我试图找出文本是否对用户可见。 为此,我使用以下代码,它与Watir-webDriver一起使用,但不适用于Watir-Classic(总是返回false):

@browser.div(:id => 'wizardPanel').p(:id => 'error2')..present?

有人可以帮助我让它在FireFox,IE,Chrome浏览器中运行吗?

1 个答案:

答案 0 :(得分:0)

尝试

@browser.div(:id => 'wizardPanel').p(:id => 'error2').visible?