我需要访问此元素:
<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 / cucumber / waiter / 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>
如何正确访问它?
答案 0 :(得分:0)
您可以使用 element.iframe(id:“ idFrame”)。iframe(id:“ idFrame2”)。input(id:“ card_number”)