From 7155f185dc09a1b74fa255ba1edd40bd5181e816 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 14 May 2015 16:59:35 +0200 Subject: [PATCH] Sometimes open of user org selection fails with selenium, add open class via ja. --- test/browser/agent_user_manage_test.rb | 13 ++++++++-- test/browser_test_helper.rb | 33 +++++++++++++++----------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/test/browser/agent_user_manage_test.rb b/test/browser/agent_user_manage_test.rb index 871261905..11fa681ad 100644 --- a/test/browser/agent_user_manage_test.rb +++ b/test/browser/agent_user_manage_test.rb @@ -22,9 +22,13 @@ class AgentUserManageTest < TestCase click( css: 'a[href="#new"]' ) click( css: 'a[href="#ticket/create"]' ) click( css: '.active .newTicket [name="customer_id_completion"]' ) + + # check if pulldown is open, it's not working stable via selenium + @browser.execute_script( "$('.active .newTicket .js-recipientDropdown').hasClass('open')" ) + sleep 1 sendkey( value: :arrow_down ) - sleep 1 + sleep 0.5 click( css: '.active .newTicket .recipientList-entry.js-user-new' ) sleep 1 @@ -87,9 +91,14 @@ class AgentUserManageTest < TestCase css: '.active .newTicket input[name="customer_id_completion"]', value: customer_user_email, ) + + # check if pulldown is open, it's not working stable via selenium + @browser.execute_script( "$('.active .newTicket .js-recipientDropdown').hasClass('open')" ) + sleep 3 sendkey( value: :arrow_down ) - sleep 1 + + sleep 0.5 click( css: '.active .newTicket .recipientList-entry.js-user.is-active' ) sleep 1 diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index c19214cd0..ccd5a0666 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -238,6 +238,12 @@ class TestCase < Test::Unit::TestCase instance = params[:browser] || @browser if params[:css] instance.find_elements( { css: params[:css] } )[0].click + + # trigger also focus on input/select and textarea fields + #if params[:css] =~ /(input|select|textarea)/ + # instance.execute_script( "$('#{params[:css]}').trigger('focus')" ) + # sleep 0.2 + #end else instance.find_elements( { partial_link_text: params[:text] } )[0].click end @@ -305,6 +311,13 @@ class TestCase < Test::Unit::TestCase element = instance.find_elements( { css: params[:css] } )[0] #element.click + + # trigger also focus on input/select and textarea fields + #if params[:css] =~ /(input|select|textarea)/ + # instance.execute_script( "$('#{params[:css]}').trigger('focus')" ) + # sleep 0.2 + #end + element.clear if !params[:slow] @@ -1032,15 +1045,11 @@ wait untill text in selector disabppears # workaround, sometimes focus is not triggered element.send_keys( data[:customer] ) - sleep 4 + sleep 3.5 # check if pulldown is open, it's not working stable via selenium - res = instance.execute_script( "$('.active .newTicket .js-recipientDropdown').hasClass('open')" ) - #puts "res #{res.inspect}" - if !res - #puts "IS NOT OPEN!, open it" - instance.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" ) - end + instance.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" ) + sleep 0.5 element.send_keys( :arrow_down ) sleep 0.3 instance.find_elements( { css: '.active .newTicket .recipientList-entry.js-user.is-active' } )[0].click @@ -1156,15 +1165,11 @@ wait untill text in selector disabppears # workaround, sometimes focus is not triggered element.send_keys( data[:customer] ) - sleep 4 + sleep 3.5 # check if pulldown is open, it's not working stable via selenium - res = instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').hasClass('open')" ) - #puts "res #{res.inspect}" - if !res - #puts "IS NOT OPEN!, open it" - instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')" ) - end + instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')" ) + sleep 0.5 element.send_keys( :arrow_down ) sleep 0.3 instance.find_elements( { css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active' } )[0].click