From 46d10851a652b5d0d1b077849e6059688c7b95e6 Mon Sep 17 00:00:00 2001 From: Sanad Liaquat Date: Fri, 8 Feb 2019 11:58:15 +0500 Subject: [PATCH 1/2] Stablize select kind using retry_on_exception Introduces retry_on_exception and renames with_retry to retry_unti so its purpose is clear in presense of retry_on_exception. --- qa/qa/page/base.rb | 17 ++++++++++++++++- qa/qa/page/group/show.rb | 16 +++++++++------- qa/qa/page/main/menu.rb | 2 +- qa/qa/page/main/sign_up.rb | 2 +- qa/qa/page/project/web_ide/edit.rb | 2 +- .../1_manage/project/create_project_spec.rb | 3 +-- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index b1f27131207..afda2ad8ac7 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -33,7 +33,7 @@ module QA false end - def with_retry(max_attempts: 3, reload: false) + def retry_until(max_attempts: 3, reload: false) attempts = 0 while attempts < max_attempts @@ -48,6 +48,21 @@ module QA false end + def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.0) + attempts = 0 + + begin + yield + rescue StandardError + sleep sleep_interval + refresh if reload + attempts += 1 + + retry if attempts < max_attempts + raise + end + end + def scroll_to(selector, text: nil) page.execute_script <<~JS var elements = Array.from(document.querySelectorAll('#{selector}')); diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb index 6dd9ff997a4..9d6bd338027 100644 --- a/qa/qa/page/group/show.rb +++ b/qa/qa/page/group/show.rb @@ -45,15 +45,17 @@ module QA private def select_kind(kind) - within_element(:new_project_or_subgroup_dropdown) do - # May need to click again because it is possible to click the button quicker than the JS is bound - wait(reload: false) do - click_element :new_project_or_subgroup_dropdown_toggle + retry_on_exception(sleep_interval: 1.0) do + within_element(:new_project_or_subgroup_dropdown) do + # May need to click again because it is possible to click the button quicker than the JS is bound + wait(reload: false) do + click_element :new_project_or_subgroup_dropdown_toggle - has_element?(kind) + has_element?(kind) + end + + click_element kind end - - click_element kind end end end diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 616d50f47fc..55500e831c6 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -57,7 +57,7 @@ module QA end def go_to_profile_settings - with_retry(reload: false) do + retry_until(reload: false) do within_user_menu do click_link 'Settings' end diff --git a/qa/qa/page/main/sign_up.rb b/qa/qa/page/main/sign_up.rb index 9ca498012eb..46a105003d0 100644 --- a/qa/qa/page/main/sign_up.rb +++ b/qa/qa/page/main/sign_up.rb @@ -23,7 +23,7 @@ module QA check_element :new_user_accept_terms if has_element?(:new_user_accept_terms) - signed_in = with_retry do + signed_in = retry_until do click_element :new_user_register_button Page::Main::Menu.act { has_personal_area? } diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb index a3e126b51da..2b6c01888d5 100644 --- a/qa/qa/page/project/web_ide/edit.rb +++ b/qa/qa/page/project/web_ide/edit.rb @@ -80,7 +80,7 @@ module QA # Retry the attempt to click :commit_button just in case part of the # animation is still in process even when the buttons have the # expected visibility. - commit_success_msg_shown = with_retry do + commit_success_msg_shown = retry_until do click_element :commit_button wait(reload: false) do diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb index 2fb8402edd8..6632c2977ef 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true module QA - # Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/72 - context 'Manage', :smoke, :quarantine do + context 'Manage', :smoke do describe 'Project creation' do it 'user creates a new project' do Runtime::Browser.visit(:gitlab, Page::Main::Login) From c06002302bb639677f6092571a05b49802e2faa5 Mon Sep 17 00:00:00 2001 From: Sanad Liaquat Date: Tue, 12 Feb 2019 12:21:01 +0500 Subject: [PATCH 2/2] Add back the :quarantine tag --- .../browser_ui/1_manage/project/create_project_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb index 6632c2977ef..2fb8402edd8 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true module QA - context 'Manage', :smoke do + # Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/72 + context 'Manage', :smoke, :quarantine do describe 'Project creation' do it 'user creates a new project' do Runtime::Browser.visit(:gitlab, Page::Main::Login)