单击(在<input />上)刷新当前页面而不转发到下一页(Watir-Webdriver)

时间:2015-06-05 15:42:43

标签: javascript jquery ruby selenium-webdriver watir-webdriver

我在 Firefox 中的 watir-webdriver(MacOSX 10.10.3)上遇到问题,点击了确认按钮(输入标记)填写商业表格后。我的商务表单有一个提交按钮(输入标记),其中点击工作正常,并将我转发到我的确认页面,但是一旦我点击确认按钮处理交易,页面就会刷新并且不会转发我到下一页(收据)。点击确认按钮&#34; $(&#34; overlay_29&#34;)。show();和$(&#34; processing_29&#34;)。show();&#34; 运行并简要地向我显示我的屏幕,即交易正在处理,然后页面刷新并且没有任何反应。我手动尝试了这个过程,我的页面工作正常,一切都按照它的方式工作。

我已经研究了这个问题大约一个星期了,阅读并实现了涵盖点击问题的每个主题,等待开启或关闭DOM,fire_event,execute_script,native_event。我对这一点感到有点难过,并会感激任何帮助。

我已尝试过所有这些方法点击:

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="&nbsp;" id="twodialog_confirmation_submit_button" value="" onclick=";" type="image">&nbsp;<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" -->

0 个答案:

没有答案