fix for intermittent capybara click failure

This fix might have to be applied at more places. We will see what CI
says...
This commit is contained in:
Maikel Linke
2015-09-09 17:08:42 +10:00
parent 2e2e767564
commit 47d239ee3a

View File

@@ -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