Commit 46d10851 authored by Sanad Liaquat's avatar Sanad Liaquat

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.
parent 724e904c
...@@ -33,7 +33,7 @@ module QA ...@@ -33,7 +33,7 @@ module QA
false false
end end
def with_retry(max_attempts: 3, reload: false) def retry_until(max_attempts: 3, reload: false)
attempts = 0 attempts = 0
while attempts < max_attempts while attempts < max_attempts
...@@ -48,6 +48,21 @@ module QA ...@@ -48,6 +48,21 @@ module QA
false false
end 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) def scroll_to(selector, text: nil)
page.execute_script <<~JS page.execute_script <<~JS
var elements = Array.from(document.querySelectorAll('#{selector}')); var elements = Array.from(document.querySelectorAll('#{selector}'));
......
...@@ -45,15 +45,17 @@ module QA ...@@ -45,15 +45,17 @@ module QA
private private
def select_kind(kind) def select_kind(kind)
within_element(:new_project_or_subgroup_dropdown) do retry_on_exception(sleep_interval: 1.0) do
# May need to click again because it is possible to click the button quicker than the JS is bound within_element(:new_project_or_subgroup_dropdown) do
wait(reload: false) do # May need to click again because it is possible to click the button quicker than the JS is bound
click_element :new_project_or_subgroup_dropdown_toggle wait(reload: false) do
click_element :new_project_or_subgroup_dropdown_toggle
has_element?(kind) has_element?(kind)
end end
click_element kind click_element kind
end
end end
end end
end end
......
...@@ -57,7 +57,7 @@ module QA ...@@ -57,7 +57,7 @@ module QA
end end
def go_to_profile_settings def go_to_profile_settings
with_retry(reload: false) do retry_until(reload: false) do
within_user_menu do within_user_menu do
click_link 'Settings' click_link 'Settings'
end end
......
...@@ -23,7 +23,7 @@ module QA ...@@ -23,7 +23,7 @@ module QA
check_element :new_user_accept_terms if has_element?(:new_user_accept_terms) 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 click_element :new_user_register_button
Page::Main::Menu.act { has_personal_area? } Page::Main::Menu.act { has_personal_area? }
......
...@@ -80,7 +80,7 @@ module QA ...@@ -80,7 +80,7 @@ module QA
# Retry the attempt to click :commit_button just in case part of the # Retry the attempt to click :commit_button just in case part of the
# animation is still in process even when the buttons have the # animation is still in process even when the buttons have the
# expected visibility. # expected visibility.
commit_success_msg_shown = with_retry do commit_success_msg_shown = retry_until do
click_element :commit_button click_element :commit_button
wait(reload: false) do wait(reload: false) do
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/72 context 'Manage', :smoke do
context 'Manage', :smoke, :quarantine do
describe 'Project creation' do describe 'Project creation' do
it 'user creates a new project' do it 'user creates a new project' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment