From be11e9a1d5f0dcacdc7db730a4a5245e26f3b85b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 6 Aug 2018 12:21:44 +0200 Subject: [PATCH] Added headless support for ff and chrome. --- Gemfile.lock | 4 +- test/browser/aab_unit_test.rb | 114 ++++++++++++++++++++++++----- test/browser/abb_one_group_test.rb | 3 + test/browser_test_helper.rb | 16 +++- 4 files changed, 114 insertions(+), 23 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index d89910abc..31f9a3a69 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -145,7 +145,7 @@ GEM multipart-post (>= 1.2, < 3) faraday-http-cache (2.0.0) faraday (~> 0.8) - ffi (1.9.23) + ffi (1.9.25) ffi-compiler (0.1.3) ffi (>= 1.0.0) rake @@ -400,7 +400,7 @@ GEM sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) - selenium-webdriver (3.11.0) + selenium-webdriver (3.13.1) childprocess (~> 0.5) rubyzip (~> 1.2) shellany (0.0.1) diff --git a/test/browser/aab_unit_test.rb b/test/browser/aab_unit_test.rb index ea63b0a47..76394834c 100644 --- a/test/browser/aab_unit_test.rb +++ b/test/browser/aab_unit_test.rb @@ -5,7 +5,11 @@ class AAbUnitTest < TestCase def test_core @browser = browser_instance location(url: browser_url + '/tests_core') - sleep 10 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', @@ -15,35 +19,55 @@ class AAbUnitTest < TestCase def test_ui @browser = browser_instance location(url: browser_url + '/tests_ui') - sleep 8 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_model') - sleep 8 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_model_binding') - sleep 8 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_model_ui') - sleep 8 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_ticket_selector') - sleep 8 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', @@ -53,63 +77,99 @@ class AAbUnitTest < TestCase def test_form @browser = browser_instance location(url: browser_url + '/tests_form') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_trim') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_find') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_timer') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_extended') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_searchable_select') - sleep 2 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_tree_select') - sleep 2 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_column_select') - sleep 2 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_form_validation') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', @@ -119,28 +179,44 @@ class AAbUnitTest < TestCase def test_table @browser = browser_instance location(url: browser_url + '/tests_table') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_table_extended') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_html_utils') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', ) location(url: browser_url + '/tests_taskbar') - sleep 4 + watch_for( + css: '.result', + value: 'Tests completed', + timeout: 8, + ) match( css: '.result .failed', value: '0', diff --git a/test/browser/abb_one_group_test.rb b/test/browser/abb_one_group_test.rb index 5ce00ffee..70a58a0e9 100644 --- a/test/browser/abb_one_group_test.rb +++ b/test/browser/abb_one_group_test.rb @@ -227,6 +227,9 @@ class AgentTicketActionLevel0Test < TestCase }, ) + # wait to push new group dependencies to browser (to show group selection) + sleep 12 + # create new ticket ticket1 = ticket_create( data: { diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 0188eb46f..d6a3b8679 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -51,7 +51,19 @@ class TestCase < Test::Unit::TestCase def browser_instance @browsers ||= {} if ENV['REMOTE_URL'].blank? - local_browser = Selenium::WebDriver.for(browser.to_sym, profile: profile) + params = { + profile: profile, + } + if ENV['BROWSER_HEADLESS'].present? + if browser == 'firefox' + params[:options] = Selenium::WebDriver::Firefox::Options.new + params[:options].add_argument('-headless') + elsif browser == 'chrome' + params[:options] = Selenium::WebDriver::Chrome::Options.new + params[:options].add_argument('-headless') + end + end + local_browser = Selenium::WebDriver.for(browser.to_sym, params) @browsers[local_browser.hash] = local_browser browser_instance_preferences(local_browser) return local_browser @@ -2020,7 +2032,7 @@ wait untill text in selector disabppears assert_equal(3, count, 'check if owner selection is - selection + master + agent per default') else - # check count of agents, should be only 1 / - selection on init screen + # check count of agents, should be only 1 selection, the "-" selection on init screen if !params[:disable_group_check] count = instance.find_elements(css: '.content.active .newTicket select[name="owner_id"] option').count if count != 1