From 6b50097f95ae998cf2ade37d1d12770304bb9cec Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 20 Jul 2018 14:04:05 +0200 Subject: [PATCH] Added browser test helper to navigate to overview by name or link. --- test/browser_test_helper.rb | 61 +++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 3556a0d20..01a45f341 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -2497,6 +2497,53 @@ wait untill text in selector disabppears true end +=begin + + overview_open( + browser: browser2, + name: overview_name, + ) + + overview_open( + browser: browser2, + link: "#ticket/view/some_special_name", + ) + +=end + + def overview_open(params) + switch_window_focus(params) + log('overview_open', params) + + instance = params[:browser] || @browser + + # click on overview task in sidebar + instance.find_elements(css: '.js-overviewsMenuItem')[0].click + + # show larger overview selection list + sleep 0.5 + execute( + browser: instance, + js: '$(".content.active .sidebar").css("display", "block")', + ) + + link = if params[:link] + params[:link] + elsif params[:name] + "\#ticket/view/#{params[:name]}" + end + + # switch to overview + instance.find_elements(css: ".content.active .sidebar a[href=\"#{link}\"]")[0].click + + # hide larger overview selection list again + sleep 0.5 + execute( + browser: instance, + js: '$(".content.active .sidebar").css("display", "none")', + ) + end + =begin ticket_open_by_overview( @@ -2520,18 +2567,8 @@ wait untill text in selector disabppears instance = params[:browser] || @browser - instance.find_elements(css: '.js-overviewsMenuItem')[0].click - sleep 0.5 - execute( - browser: instance, - js: '$(".content.active .sidebar").css("display", "block")', - ) - instance.find_elements(css: ".content.active .sidebar a[href=\"#{params[:link]}\"]")[0].click - sleep 0.5 - execute( - browser: instance, - js: '$(".content.active .sidebar").css("display", "none")', - ) + overview_open(params) + if params[:title] element = instance.find_element(css: '.content.active').find_element(partial_link_text: params[:title]) if !element