Sometimes open of user org selection fails with selenium, add open class via ja.

This commit is contained in:
Martin Edenhofer 2015-05-14 16:59:35 +02:00
parent 7d6b6d02a4
commit 7155f185dc
2 changed files with 30 additions and 16 deletions

View file

@ -22,9 +22,13 @@ class AgentUserManageTest < TestCase
click( css: 'a[href="#new"]' ) click( css: 'a[href="#new"]' )
click( css: 'a[href="#ticket/create"]' ) click( css: 'a[href="#ticket/create"]' )
click( css: '.active .newTicket [name="customer_id_completion"]' ) 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 sleep 1
sendkey( value: :arrow_down ) sendkey( value: :arrow_down )
sleep 1 sleep 0.5
click( css: '.active .newTicket .recipientList-entry.js-user-new' ) click( css: '.active .newTicket .recipientList-entry.js-user-new' )
sleep 1 sleep 1
@ -87,9 +91,14 @@ class AgentUserManageTest < TestCase
css: '.active .newTicket input[name="customer_id_completion"]', css: '.active .newTicket input[name="customer_id_completion"]',
value: customer_user_email, 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 sleep 3
sendkey( value: :arrow_down ) sendkey( value: :arrow_down )
sleep 1
sleep 0.5
click( css: '.active .newTicket .recipientList-entry.js-user.is-active' ) click( css: '.active .newTicket .recipientList-entry.js-user.is-active' )
sleep 1 sleep 1

View file

@ -238,6 +238,12 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
if params[:css] if params[:css]
instance.find_elements( { css: params[:css] } )[0].click 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 else
instance.find_elements( { partial_link_text: params[:text] } )[0].click instance.find_elements( { partial_link_text: params[:text] } )[0].click
end end
@ -305,6 +311,13 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { css: params[:css] } )[0] element = instance.find_elements( { css: params[:css] } )[0]
#element.click #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 element.clear
if !params[:slow] if !params[:slow]
@ -1032,15 +1045,11 @@ wait untill text in selector disabppears
# workaround, sometimes focus is not triggered # workaround, sometimes focus is not triggered
element.send_keys( data[:customer] ) element.send_keys( data[:customer] )
sleep 4 sleep 3.5
# check if pulldown is open, it's not working stable via selenium # check if pulldown is open, it's not working stable via selenium
res = instance.execute_script( "$('.active .newTicket .js-recipientDropdown').hasClass('open')" ) instance.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" )
#puts "res #{res.inspect}" sleep 0.5
if !res
#puts "IS NOT OPEN!, open it"
instance.execute_script( "$('.active .newTicket .js-recipientDropdown').addClass('open')" )
end
element.send_keys( :arrow_down ) element.send_keys( :arrow_down )
sleep 0.3 sleep 0.3
instance.find_elements( { css: '.active .newTicket .recipientList-entry.js-user.is-active' } )[0].click 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 # workaround, sometimes focus is not triggered
element.send_keys( data[:customer] ) element.send_keys( data[:customer] )
sleep 4 sleep 3.5
# check if pulldown is open, it's not working stable via selenium # check if pulldown is open, it's not working stable via selenium
res = instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').hasClass('open')" ) instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')" )
#puts "res #{res.inspect}" sleep 0.5
if !res
#puts "IS NOT OPEN!, open it"
instance.execute_script( "$('.modal .user_autocompletion .js-recipientDropdown').addClass('open')" )
end
element.send_keys( :arrow_down ) element.send_keys( :arrow_down )
sleep 0.3 sleep 0.3
instance.find_elements( { css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active' } )[0].click instance.find_elements( { css: '.modal .user_autocompletion .recipientList-entry.js-user.is-active' } )[0].click