From 7f3dcc5fa89f74af4a9067540198d7f5ae72f97d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 22 Feb 2015 23:51:44 +0100 Subject: [PATCH] Improved speed of tests. --- .../agent_ticket_overview_level1_test.rb | 73 +++++++++++++++++++ test/browser_test_helper.rb | 40 ++++++---- 2 files changed, 97 insertions(+), 16 deletions(-) diff --git a/test/browser/agent_ticket_overview_level1_test.rb b/test/browser/agent_ticket_overview_level1_test.rb index 05dc312e0..69bb43153 100644 --- a/test/browser/agent_ticket_overview_level1_test.rb +++ b/test/browser/agent_ticket_overview_level1_test.rb @@ -77,7 +77,80 @@ class AgentTicketOverviewLevel1Test < TestCase ) # use overview navigation to got to #2 & #3 + match( + :browser => browser2, + :css => '.active .ticketZoom .overview-navigator .pagination-counter', + :value => '1/3', + ) + match( + :browser => browser2, + :css => '.active .page-header .ticket-number', + :value => ticket1[:number], + ) + click( + :browser => browser2, + :css => '.ticketZoom .overview-navigator .next', + ) + match( + :browser => browser2, + :css => '.active .ticketZoom .overview-navigator .pagination-counter', + :value => '2/3', + ) + match( + :browser => browser2, + :css => '.active .page-header .ticket-number', + :value => ticket2[:number], + ) + click( + :browser => browser2, + :css => '.ticketZoom .overview-navigator .next', + ) + match( + :browser => browser2, + :css => '.active .ticketZoom .overview-navigator .pagination-counter', + :value => '3/3', + ) + match( + :browser => browser2, + :css => '.active .page-header .ticket-number', + :value => ticket3[:number], + ) + + # close ticket + ticket_update( + :browser => browser2, + :data => { + :state => 'closed', + } + ) + sleep 8 + + match( + :browser => browser2, + :css => '.active .ticketZoom .overview-navigator .pagination-counter', + :value => '3/3', + ) + match( + :browser => browser2, + :css => '.active .page-header .ticket-number', + :value => ticket3[:number], + ) + click( + :browser => browser2, + :css => '.ticketZoom .overview-navigator .previous', + ) + + match( + :browser => browser2, + :css => '.active .ticketZoom .overview-navigator .pagination-counter', + :value => '2/2', + ) + match( + :browser => browser2, + :css => '.active .page-header .ticket-number', + :value => ticket2[:number], + ) end end \ No newline at end of file diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 2e945a823..3ff58ac04 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -495,23 +495,27 @@ class TestCase < Test::Unit::TestCase for i in 1..100 sleep 1 - if instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0] - instance.mouse.move_to( instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0] ) - sleep 0.2 + begin + if instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0] + instance.mouse.move_to( instance.find_elements( { :css => '.navigation .tasks .task:first-child' } )[0] ) + sleep 0.2 - click_element = instance.find_elements( { :css => '.navigation .tasks .task:first-child .js-close' } )[0] - if click_element - sleep 0.1 - click_element.click + click_element = instance.find_elements( { :css => '.navigation .tasks .task:first-child .js-close' } )[0] + if click_element + sleep 0.1 + click_element.click - # accept task close warning - if params[:discard_changes] - sleep 1 - instance.find_elements( { :css => '.modal button.js-submit' } )[0].click + # accept task close warning + if params[:discard_changes] + sleep 1 + instance.find_elements( { :css => '.modal button.js-submit' } )[0].click + end end + else + break end - else - break + rescue + # just try again end end assert( true, "all tasks closed" ) @@ -712,9 +716,13 @@ class TestCase < Test::Unit::TestCase found = nil (1..5).each {|loop| if !found - text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text - if text =~ /(Discard your unsaved changes.|Verwerfen der)/ - found = true + begin + text = instance.find_elements( { :css => '.content.active .js-reset' } )[0].text + if text =~ /(Discard your unsaved changes.|Verwerfen der)/ + found = true + end + rescue + # just try again end sleep 1 end