2016-06-21 4 views
0

キュウリ試験に問題があります。 Paylane経由での支払い後(何とかPaylaneのシナリオにのみ問題があります; Paypal、Stripe、Payuはうまく動作します)、「ありがとうございました」ページでは、Capybaraのように見えます(店に戻るために)ブラウザで強調表示されますが、何もしない。また、次のステップに進み、店舗ページにあるかどうかを確認して、ボタンをクリックしたことがうまくいったと思うかどうかを確認します(私は思います)。誰かが私を助けることができますか?カピバラがボタンをきちんとクリックしたようですが、次のページに進まない


@lp @purchase @paylane @javascript 
Feature: Purchase a product from a Landing Page via Paylane 
    As a Sneakpick user 
    I can access Landing Pages of product 
    So I can successfully purchase it via Paylane 

    Scenario: Purchase product via Paylane # features/purchases/landing_page/paylane.feature:7 
    Given I visit the Landing Page  # features/step_definitions/basic_steps.rb:5 
    Then I want to order 1 product  # features/step_definitions/purchase_steps.rb:92 
    And product is available via Paylane # features/step_definitions/purchase_steps.rb:1 
DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:erb] instead. (called from _app_views_paylane_pay_html_erb___1015711955565910954_70249561011280 at /home/szczepan/1000i/Git/sneakpick/app/views/paylane/pay.html.erb:2) 
    Then I go to payment     # features/step_definitions/purchase_steps.rb:53 
    And I pay via Paylane    # features/step_definitions/paylane_steps.rb:1 
     expected to find text "Product" in "Payment - Sneakpick.co Thank You! Your order has been processed. We've sent you a confirmation emailwith your order details. « Back to product powered by sneakpick" (RSpec::Expectations::ExpectationNotMetError) 
     ./features/step_definitions/purchase_steps.rb:77:in `/^I am on Landing page$/' 
     ./features/step_definitions/paylane_steps.rb:2:in `/^I pay via Paylane$/' 
     features/purchases/landing_page/paylane.feature:12:in `And I pay via Paylane' 
    And my Paylane order should be made # features/step_definitions/paylane_steps.rb:76 

    Scenario: Purchase product via Paylane    # features/purchases/landing_page/paylane.feature:15 
    Given I visit the Landing Page     # features/step_definitions/basic_steps.rb:5 
    Then I want to order 1 product     # features/step_definitions/purchase_steps.rb:92 
    And product is available via Paylane    # features/step_definitions/purchase_steps.rb:1 
DEPRECATION WARNING: Passing a template handler in the template name is deprecated. You can simply remove the handler name or pass render :handlers => [:erb] instead. (called from _app_views_paylane_pay_html_erb___1015711955565910954_70249561011280 at /home/szczepan/1000i/Git/sneakpick/app/views/paylane/pay.html.erb:2) 
    Then I go to payment        # features/step_definitions/purchase_steps.rb:53 
    And I pay via Paylane not with card successfully # features/step_definitions/paylane_steps.rb:13 
    And my Paylane order should be made    # features/step_definitions/paylane_steps.rb:76 

ああ、2番目のものはうまくいきますが、最初は1つではなく、同じボタンをクリックします。ここ は、手順は次のとおりです。


And /^I pay via Paylane$/ do 
    steps %(
    And I check if Paylane form is filled with correct data 
    And I fill in the card data 
    And I send form 
    And I accept confirmation alert 
    And I am on Thank You page 
    And I click 'Back to product' button 
    And I am on Landing page 
) 
end 

And /^I pay via Paylane not with card successfully$/ do 
    steps %(
    And I choose last available payment 
    And I send form 
    And I accept confirmation alert 
    And I click 'SUCCESS' button 
    And I am on Thank You page 
    And I click 'Back to product' button 
    And I am on Landing page 
) 
end 

そして "Iボタンをクリックします(+。)" のステップ:


And /^I click '(.+)' button$/ do |button| 
    click_on(button) 
end 

ボタンは、 "製品に戻る" というテキストが含まれています。

助けていただけたら幸いです!

+0

問題を引き起こしていたクリックする前に睡眠を追加してくれました。しかし、これは一時的な解決策のように扱っています。キュウリのトラブルがありますか? – sbulat

答えて

0

これはRuby-Cucumberの少なくとも1つの典型的な解決策の1つで、wait_for_ajaxのような単純な方法です。基本的には、それ以上のアクティブなHTTP呼び出しがないことを登録するまでブロックします。これは、通常、カピバラ内でステップ定義からの関数呼び出しとして実行されます。 (特にサードパーティーのページで)待たなければならないと思ったときは、特に何かをクリックするなどのアクションを取った後、ステップデフを通してこのことを自由に振りかざしてください。あらかじめ決められた時間だけsleep()と呼ぶよりはるかに信頼できます。

def wait_for_ajax 
    Timeout.timeout(Capybara.default_max_wait_time) do 
     loop until finished_all_ajax_requests? 
    end 
end 

def finished_all_ajax_requests? 
    page.evaluate_script('jQuery.active').zero? 
end 

出典:元のソースコード(それはしばらくしている)と、個人的な経験のためThoughtbotが信頼できないカピバラ/キュウリのテストスイートを固定しています。

最後に、Capybaraのsteps%(...)の構文は廃止されましたが、代わりにstep '...'という個別の手順を呼び出す必要があります。これは、関数呼び出し(より正確には、この種のもの)のようなステップデフを扱うことができます。

関連する問題