Javascript 单击(在<;输入>;)刷新当前页面而不转发到下一页(Watir Webdriver)
我在Firefox中的watir webdriver(MacOSX 10.10.3)上遇到问题,在填写商业表单后单击确认按钮(输入标签)。我的商业表单有一个提交按钮(输入标签),点击可以正常工作,并将我转发到我的确认页面,但一旦我点击确认按钮处理交易,页面就会刷新,而不会将我转发到下一页(收据)。单击确认按钮“$(“overlay_29”).show();和$(“processing_29”).show()”运行并简要显示我的屏幕,显示to transaction正在处理,然后页面刷新,什么也没有发生。我已经手动尝试了这个过程,我的页面运行良好,一切都按照预期的方式运行 我已经研究这个问题大约一周了,阅读并实现了每一个主题,包括点击问题、等待DOM、fire_事件、执行_脚本、本地_事件打开或关闭。我在这个问题上有点困惑,希望能得到任何帮助 我尝试了所有这些方法来单击:Javascript 单击(在<;输入>;)刷新当前页面而不转发到下一页(Watir Webdriver),javascript,jquery,ruby,selenium-webdriver,watir-webdriver,Javascript,Jquery,Ruby,Selenium Webdriver,Watir Webdriver,我在Firefox中的watir webdriver(MacOSX 10.10.3)上遇到问题,在填写商业表单后单击确认按钮(输入标签)。我的商业表单有一个提交按钮(输入标签),点击可以正常工作,并将我转发到我的确认页面,但一旦我点击确认按钮处理交易,页面就会刷新,而不会将我转发到下一页(收据)。单击确认按钮“$(“overlay_29”).show();和$(“processing_29”).show()”运行并简要显示我的屏幕,显示to transaction正在处理,然后页面刷新,什么也没
b = @browser
b.button(:src=> /btn_confirm/).click
b.button(:src=> /btn_confirm/).when_present.click
b.button(:src=> /btn_confirm/).fire_event "onclick"
b.input(:src=> /btn_confirm/).click
b.input(:src=> /btn_confirm/).when_present.click
b.input(:src=> /btn_confirm/).fire_event "onclick"
当我运行这些方法时,它们都是真的:
b = @browser
puts b.button(:src=> /btn_confirm/).exists?
puts b.button(:src=> /btn_confirm/).enabled?
puts b.button(:src=> /btn_confirm/).visible?
我已经尝试了以下watir webdriver版本
0.6.4-0.7.0
我尝试过每一个不是v17-v38测试版的Firefox版本,每一个watir webdriver gem版本都没有成功
这是html格式:
<!-- Generated Form CSS Start name="Confirm Payment Details" -->
<style type="text/css">
</style>
<!-- Generated Form CSS End name="Confirm Payment Details" -->
<!-- Generated Form HTML Start name="Confirm Payment Details" -->
<div id="twodialog_commerce_form_wrapper_5" class="commForm1 twodialog_form_wrapper twodialogEditableElement">
<h2 id="twodialog_commerce_form_description" class="twodialog_form_description twodialogEditableElement">Confirm Payment Details</h2>
<form class="twodialog_form twodialogEditableElement" id="commerce_5" name="commerce_5" target="_self" action="https://secure.2dialog.com/mt5/main.php/micro_sites/showpage/id/1/page_number/2" method="POST">
<input id="CommerceID" name="CommerceID" value="5" type="hidden">
<input name="widget_id" value="29" type="hidden">
<div id="twodialog_form_cart_wrapper" class="twodialog_form_cart">
<h2 class="twodialog_form_cart_description">Your Donation</h2>
<table id="twodialog_form_cart_table" class="twodialog_form_cart_table">
<thead>
<tr>
<th class="title_item" style="width: 75%;">Item</th>
<th class="title_amount">Cost</th>
</tr>
</thead>
<tbody>
<tr class="cartItem cartItemOneTime rowEven" id="cartRow2">
<td class="name">
<b>$10.00 Donation.</b><br>
<i>Donate $10.00.</i>
</td>
<td class="cost">
$10.00
<br><a href="#" onclick="removeCartItem('/mt5/main.php/micro_sites/', 2, 'one_time',0, 0); return false;">remove</a></td>
</tr>
<tr class="cartItem cartItemOneTime rowOdd" id="cartRow3">
<td class="name">
<b>$20.00 Donation.</b><br>
<i>Donate $20.00.</i>
</td>
<td class="cost">
$20.00
<br><a href="#" onclick="removeCartItem('/mt5/main.php/micro_sites/', 3, 'one_time',0, 0); return false;">remove</a></td>
</tr>
<tr><td class="cartEmpty cartEmptyOneTime" colspan="2" style="display: none" align="center">Your cart is empty</td></tr>
</tbody>
<tfoot>
<tr>
<td colspan="1" class="alignRight total_label"><label>Total:</label></td>
<td class="total_value">$30.00</td>
</tr>
</tfoot>
</table>
</div>
<h2 id="twodialog_form_commerce_description" class="twodialog_form_description twodialogEditableElement">Credit Card Information</h2>
<div id="twodialog_form_commerce_wrapper" class="twodialog_form_commerce twodialogEditableElement">
<div id="twodialog_form_commerce_card_type_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_card_type_label" class="twodialog_form_label twodialogEditableElement">Card Type<span id="twodialog_form_commerce_card_type_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
Visa
</div>
<div id="twodialog_form_commerce_card_number_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_card_number_label" class="twodialog_form_label twodialogEditableElement">Card Number<span id="twodialog_form_commerce_card_number_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
***********4290
</div>
<div id="twodialog_form_commerce_card_cvv_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_card_cvv_label" class="twodialog_form_label twodialogEditableElement">CVV<span id="twodialog_form_commerce_card_cvv_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
***
</div>
<div id="twodialog_form_commerce_card_expiration_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_card_expiration_label" class="twodialog_form_label twodialogEditableElementl">Expiration<span id="twodialog_form_commerce_card_expiration_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
6/2015
</div>
<div id="twodialog_form_commerce_card_name_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_card_name_label" class="twodialog_form_label twodialogEditableElement">Name on Card<span id="twodialog_form_commerce_card_name_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
DonFN DonLN
</div>
<div id="twodialog_form_commerce_billing_address_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_billing_address_label" class="twodialog_form_label twodialogEditableElement">Address<span id="twodialog_form_commerce_billing_address_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
123 Fruitful Ln
</div>
<div id="twodialog_form_commerce_billing_city_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_billing_city_label" class="twodialog_form_label twodialogEditableElement">City<span id="twodialog_form_commerce_billing_city_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
New York
</div>
<div id="twodialog_form_commerce_billing_state_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_billing_state_label" class="twodialog_form_label twodialogEditableElement">State / Province<span id="twodialog_form_commerce_billing_state_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
<span id="CCDetails_State" class="twodialogEditableElement">NY</span>
</div>
<div id="twodialog_form_commerce_billing_postal_code_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_billing_postal_code_label" class="twodialog_form_label twodialogEditableElement">Postal Code<span id="twodialog_form_commerce_billing_postal_code_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
12345
</div>
<div id="twodialog_form_commerce_billing_country_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_billing_country_label" class="twodialog_form_label twodialogEditableElement">Country<span id="twodialog_form_commerce_billing_country_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
<span id="CCDetails_Country" class="twodialogEditableElement">United States</span>
</div>
<div id="twodialog_form_commerce_billing_phone_row" class="twodialog_form_item_list_row twodialogEditableElement odd">
<label id="twodialog_form_commerce_billing_phone_label" class="twodialog_form_label twodialogEditableElement">Phone</label>
</div>
<div id="twodialog_form_commerce_billing_email_row" class="twodialog_form_item_list_row twodialogEditableElement even">
<label id="twodialog_form_commerce_billing_email_label" class="twodialog_form_label twodialogEditableElement">Email Address<span id="twodialog_form_commerce_billing_email_required_symbol" class="twodialog_form_required twodialogEditableElement">*</span></label>
donfnln@mail.com
</div>
</div>
<p id="twodialog_form_control_5" class="twodialog_form_control twodialogEditableElement"><input class="twodialog_form_button_confirm processorButton_29 zaptastic twodialogEditableElement twodialogEditableElement" name="commit" src="https://secure.2dialog.com/mt5/images/btn_confirm.png" alt=" " id="twodialog_confirmation_submit_button" value="" onclick=";" type="image"> <input class="twodialog_form_button_change twodialogEditableElement twodialogEditableElement" name="cancel" src="https://secure.2dialog.com/mt5/images/btn_change.png" alt="change" id="twodialog_confirmation_cancel_button" value="change" onclick=";" type="image">
</p>
<div class="processorOverlay" id="overlay_29" style="display: none;"></div>
<div class="processorMessage" id="processing_29" style="display: none">
Please wait while we process your credit card.
</div>
</form>
</div>
<!-- Generated Form HTML End name="Confirm Payment Details" -->
<!-- Generated Form JS Start name="Confirm Payment Details" -->
<script type="text/javascript">
Event.observe(document, "dom:loaded", function(){
getCurrentStateLabel("/mt5/main.php/micro_sites/", "COM", function(label){
$("CCDetails_State").update(label);
});
getCurrentCountryLabel("/mt5/main.php/micro_sites/", "COM", function(label){
$("CCDetails_Country").update(label);
});
if(true)
{
$$(".processorButton_29").each(function(element){
element.observe("click", function(event){
$("overlay_29").show();
$("processing_29").show();
});
});
}
});
</script>
<!-- Generated Form JS End name="Confirm Payment Details" -->
确认付款详情
你的捐款
项目
费用
10.00美元捐款。
捐赠10美元。
$10.00
20.00美元捐款。
捐赠20美元。
$20.00
你的车是空的
总数:
$30.00
信用卡信息
卡片类型*
签证
卡号*
***********4290
CVV*
***
到期日*
6/2015
卡片上的名字*
多恩多恩
地址*
123富有成果的Ln
城市*
纽约
州/省*
纽约
邮政编码*
12345
国家*
美国
电话
电子邮件地址*
donfnln@mail.com
我们正在处理您的信用卡,请稍候。
Event.observe(文档“dom:loaded”,function()){
getCurrentStateLabel(“/mt5/main.php/micro_sites/”,“COM”,函数(标签){
$(“CCU状态”)。更新(标签);
});
getCurrentCountryLabel(“/mt5/main.php/micro_sites/”,“COM”,函数(label){
$(“CCU国家/地区”)。更新(标签);
});
如果(真)
{
$$(“.processorButton_29”)。每个(函数(元素){
元素。观察(“点击”),功能(事件){
$(“overlay_29”).show();
$(“processing_29”).show();
});
});
}
});
您特别提到问题出在Firefox中。这是否意味着它可以在其他浏览器中正常工作(比如Chrome)?我知道Firefox和Chrome点击元素的方式至少有一个区别(虽然不太可能与你的问题有关)。它只是在Firefox中不起作用。如果使用:id=>“twodialog\u confirmation\u submit\u button”
,以同一字段的id
为目标,它是否起作用?如果我以id
为目标,它也不起作用。我已经尝试了输入标签上的所有属性。