我使用PageObject和watir。我需要在框架中找到文本字段。
HTML:
<iframe id="iframeorderTab1" width="100%" height="100%" src="/GenePortal_zt40/SCC.Requisitions/Requisition/Requisition?tabId=orderTab1&reqNum=&mode=Edit&templateId=&patientMRN=">
....
<input id="lastName-inputEl" class="x-form-field x-form-text " type="text" autocomplete="off" style="background-image: none; background-color: rgb(240, 224, 163); text-transform: uppercase; width: 100%;" maxlength="35" name="lastName-inputEl" size="1" role="textbox" data-errorqtip="">
红宝石:
class ReqEntryPage
include PageObject
in_frame(:id=>"iframeorderTab1") do |frame|
text_field(:lastName,:name=>"lastName-inputEl", :frame=>frame)
end
public
def fill_in_requisition_and_release(browser)
Watir::Wait.until do
if self.lastName? then
puts "====================!!!FOUND!!!====================="
end
end
end
end
系统找不到lastName元素。我究竟做错了什么?
我假设您使用的是最新版本的Page-Object gem。Watir-Webdriver API中最近发生了变化,它为定位框架和iframe提供了单独的方法(与以前一样,使用相同的方法来定位这两个方法)。Page-Object gem API已更新为一致。
这意味着您的访问者当前正在寻找:
<frame id="iframeorderTab1">
<input name="lastName-inputEl">
</frame>
这将与您的html不匹配,因为您拥有一个iframe。要在iframe中定位,您需要in_iframe
改用:
in_iframe(:id=>"iframeorderTab1") do |frame|
text_field(:lastName,:name=>"lastName-inputEl", :frame=>frame)
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句