Ruby 无法访问文本字段-watir

Ruby 无法访问文本字段-watir,ruby,watir,watir-webdriver,Ruby,Watir,Watir Webdriver,我在结账页面的最后一页。当我加载结帐页面一秒钟后,就会出现允许用户输入信用卡信息的字段。据我所知,信用卡字段是由信用卡公司注入页面的 付款代码部分如下所示: <div id="block-system-main" class="block block-system block-main block-system-main even block-without-title"> <div class="content clearfix"> <form id="lb-bo

我在结账页面的最后一页。当我加载结帐页面一秒钟后,就会出现允许用户输入信用卡信息的字段。据我所知,信用卡字段是由信用卡公司注入页面的

付款代码部分如下所示:

<div id="block-system-main" class="block block-system block-main block-system-main even block-without-title">
<div class="content clearfix">
<form id="lb-booking-booking-alt-payment" class="booking-form jquery-once-1-processed" accept-charset="UTF-8" method="post" action="/booking/payment">
<div>
<div id="lb-card-options">
<fieldset id="edit-payment-detail" class="form-wrapper">
<legend>
<div class="fieldset-wrapper">
<div id="edit-payment-details-amount-to-pay" class="form-item form-type-yachts-item">
<div id="edit-payment-details-wrapper-payment-iframe" class="lb-booking-payment-iframe-wrapper form-wrapper">
<iframe class="lb-booking-payment-iframe payment_iframe-processed" width="100%" src="https://testing.datapayment.com/hps/?HPS_SessionID=0c2181c579-d532a6-4217a-929a-e59562af8474ea09" style="height: 388px;">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html class="mti-inactive" lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<body leftmargin="0" topmargin="0">
<form class="payment-form" autocomplete="off" method="post" action="?">
<div class="gateway-form clearfix three-column-with-button">
<div class="form-fields form-wrapper clearfix">
<div class="form-item form-type-textfield">
<label for="card_number">
<input id="card_number" class="form-text required" type="text" maxlength="23" size="26" name="card_number">
</div>

不能以与其他字段相同的方式直接访问iframe中的字段,需要先访问iframe的作用域:

b.iframe(class: "lb-booking-payment-iframe").text_field(id: 'card_number').set '999999999'

从所提供的HTML中,该元素看起来像是在。您需要指定:

b.iframe(:class => "lb-booking-payment-iframe payment_iframe-processed").text_field(:id => 'card_number').set '9999999999'

这将失败,因为它不是完整的类ID。您可以使用/lb booking payment ifream/。
b.iframe(:class => "lb-booking-payment-iframe payment_iframe-processed").text_field(:id => 'card_number').set '9999999999'