Question

I use PageObject and watir. And I need to find text field in frame.

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="">

Ruby:

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

System doesn't found lastName element. What am i doing wrong?

Was it helpful?

Solution

I assume you are using the latest version of the Page-Object gem. There was a recent change in the Watir-Webdriver API that made separate methods for locating frames vs iframes (where as before the same method was used to locate both). The Page-Object gem API was updated to be consistent.

This means that your accessor is currently looking for:

<frame id="iframeorderTab1">
  <input name="lastName-inputEl">
</frame>

Which will not match your html as you have an iframe instead. To locate within an iframe, you need to use in_iframe instead:

in_iframe(:id=>"iframeorderTab1") do |frame|
  text_field(:lastName,:name=>"lastName-inputEl", :frame=>frame)
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top