(黄瓜/红宝石/页面对象)使用 PageObject 访问 iframe/iframe 中的输入(表单)元素



我需要访问这个元素:

<input type="tel" pattern="[0-9 ]*" name="card_number" id="card_number" autocomplete="off" size="22" class="input-outline-none">

它像这样放置在第二个 iframe 中(我说得很简单,不要太复杂):

<iframe scrolling="no" data-aura-rendered-by="203:0" id="<<iframe_id>>" src="<<iframe_url>>" width="100%" height="95px" frameborder="0">
#document
 <!DOCTYPE html PUBLIC .....>
(...)
<iframe scrolling="no" id="<<iframe2_id>>" name="<<iframe2_name>>" src="<<iframe2_url"" width="100%" height="100%" frameborder="0">
#document
 <!DOCTYPE html PUBLIC .....>
(...)
<form accept-charset="UTF-8" action="javascript:void(0);" id="number-form" onsubmit="return false;">
    <label for="card_number" class="visuallyhidden" id="number_label">Card Number</label>
    <input type="tel" pattern="[0-9 ]*" name="card_number" id="card_number" autocomplete="off" size="22" class="input-outline-none">
    (...)
  </form>
(...)
</iframe>
</iframe>

我尝试像这样访问它(使用 Ruby/黄瓜/waitr/PageObject):

 in_iframe(:id => 'YPWNwIjOrg') do |outer_iframe|
    in_iframe({:id => 'spreedly-number-frame-9437'}, outer_iframe) do |inner_iframe|
      element(:cc_num, :id => "card_number", :frame => inner_iframe)
    end
  end

我收到此错误消息:

with exception: timed out after 30 seconds, waiting for #<Watir::IFrame: located: false; {:id=>"<<iframe_id>>", :tag_name=>"iframe"}> to be located
Browser driver used: #<Selenium::WebDriver::Chrome::Driver:0x00007fc1e33d7910>

如何正确访问它?

您可以使用

element.iframe(id: "idFrame").iframe(id: "idFrame2").input(id: "card_number")

相关内容

  • 没有找到相关文章

最新更新