From 47d239ee3a9d5793567107f2da9e36239a2a14dd Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 9 Sep 2015 17:08:42 +1000 Subject: [PATCH] fix for intermittent capybara click failure This fix might have to be applied at more places. We will see what CI says... --- spec/features/admin/orders_spec.rb | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/spec/features/admin/orders_spec.rb b/spec/features/admin/orders_spec.rb index eec021f1f9..4a30c3a60c 100644 --- a/spec/features/admin/orders_spec.rb +++ b/spec/features/admin/orders_spec.rb @@ -50,11 +50,12 @@ feature %q{ scenario "can add a product to an existing order", js: true do login_to_admin_section visit '/admin/orders' - page.find('td.actions a.icon-edit').click - targetted_select2_search @product.name, from: ".variant_autocomplete", dropdown_css: ".select2-search" + click_edit - click_icon :plus + targetted_select2_search @product.name, from: '#add_variant_id', dropdown_css: '.select2-drop' + + click_link 'Add' page.should have_selector 'td', text: @product.name @order.line_items(true).map(&:product).should include @product @@ -153,4 +154,21 @@ feature %q{ end end + + # Working around intermittent click failing + # Possible causes of failure: + # - the link moves + # - the missing content (font icon only) + # - the screen is not big enough + # However, some operations before the click or a second click on failure work. + # + # A lot of people had similar problems: + # https://github.com/teampoltergeist/poltergeist/issues/520 + # https://github.com/thoughtbot/capybara-webkit/issues/494 + def click_edit + click_result = click_icon :edit + unless click_result['status'] == 'success' + click_icon :edit + end + end end