Some stability improvements.

This commit is contained in:
Martin Edenhofer 2015-02-28 11:40:23 +01:00
parent 3d0f76cea0
commit ee8b309d7e
5 changed files with 116 additions and 30 deletions

View file

@ -38,7 +38,7 @@ class AgentOrganizationProfileTest < TestCase
sleep 2 sleep 2
# check and change note again in edit screen # check and change note again in edit screen
click( :css => '.active .js-action .select-arrow' ) click( :css => '.active .js-action .select-arrow', :fast => true )
click( :css => '.active .js-action a[data-type="edit"]' ) click( :css => '.active .js-action a[data-type="edit"]' )
watch_for( watch_for(

View file

@ -38,9 +38,11 @@ class AgentTicketOverviewLevel0Test < TestCase
# select both via bulk action # select both via bulk action
click( click(
:css => '.active table tr td input[value="' + ticket1[:id] + '"] + .checkbox', :css => '.active table tr td input[value="' + ticket1[:id] + '"] + .checkbox',
:fast => true,
) )
click( click(
:css => '.active table tr td input[value="' + ticket2[:id] + '"] + .checkbox', :css => '.active table tr td input[value="' + ticket2[:id] + '"] + .checkbox',
:fast => true,
) )
exists( exists(
:css => '.active table tr td input[value="' + ticket1[:id] + '"]:checked', :css => '.active table tr td input[value="' + ticket1[:id] + '"]:checked',
@ -60,7 +62,7 @@ class AgentTicketOverviewLevel0Test < TestCase
click( click(
:css => '.active .bulkAction .js-submit', :css => '.active .bulkAction .js-submit',
) )
sleep 3 sleep 6
exists_not( exists_not(
:css => '.active table tr td input[value="' + ticket1[:id] + '"]', :css => '.active table tr td input[value="' + ticket1[:id] + '"]',
@ -95,7 +97,7 @@ class AgentTicketOverviewLevel0Test < TestCase
:value => '#', :value => '#',
) )
match( match(
:css => '.active table th:nth-child(7)', :css => '.active table th:nth-child(8)',
:value => 'Article#', :value => 'Article#',
) )
@ -108,7 +110,7 @@ class AgentTicketOverviewLevel0Test < TestCase
:value => '#', :value => '#',
) )
match( match(
:css => '.active table th:nth-child(7)', :css => '.active table th:nth-child(8)',
:value => 'Article#', :value => 'Article#',
) )
@ -134,7 +136,7 @@ class AgentTicketOverviewLevel0Test < TestCase
:value => '#', :value => '#',
) )
exists_not( exists_not(
:css => '.active table th:nth-child(7)', :css => '.active table th:nth-child(8)',
) )
# create new ticket # create new ticket

View file

@ -26,6 +26,7 @@ class PreferencesTest < TestCase
:value => 'English (United States)', :value => 'English (United States)',
) )
click( :css => '.content button[type="submit"]' ) click( :css => '.content button[type="submit"]' )
sleep 2
watch_for( watch_for(
:css => 'body', :css => 'body',
:value => 'Language', :value => 'Language',
@ -35,10 +36,12 @@ class PreferencesTest < TestCase
:value => 'Deutsch', :value => 'Deutsch',
) )
click( :css => '.content button[type="submit"]' ) click( :css => '.content button[type="submit"]' )
sleep 2
watch_for( watch_for(
:css => 'body', :css => 'body',
:value => 'Sprache', :value => 'Sprache',
) )
sleep 2
reload() reload()
watch_for( watch_for(
:css => 'body', :css => 'body',

View file

@ -188,6 +188,7 @@ class TestCase < Test::Unit::TestCase
click( click(
:browser => browser1, :browser => browser1,
:css => '.some_class', :css => '.some_class',
:fast => false, # do not wait
) )
=end =end
@ -195,7 +196,9 @@ class TestCase < Test::Unit::TestCase
def click(params) def click(params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
instance.find_elements( { :css => params[:css] } )[0].click instance.find_elements( { :css => params[:css] } )[0].click
sleep 0.5 if !params[:fast]
sleep 0.4
end
end end
=begin =begin
@ -249,14 +252,6 @@ class TestCase < Test::Unit::TestCase
def set(params) def set(params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
# it's not working stable via selenium, use js
if params[:contenteditable]
#puts "---$('#{params[:css]}').html('#{params[:value]}')--"
instance.execute_script( "$('#{params[:css]}').focus().html('#{params[:value]}').trigger('change').blur()" )
sleep 1
return
end
element = instance.find_elements( { :css => params[:css] } )[0] element = instance.find_elements( { :css => params[:css] } )[0]
#element.click #element.click
element.clear element.clear
@ -274,6 +269,15 @@ class TestCase < Test::Unit::TestCase
if params[:blur] if params[:blur]
instance.execute_script( "$('#{params[:css]}').blur()" ) instance.execute_script( "$('#{params[:css]}').blur()" )
end end
# it's not working stable via selenium, use js
if params[:contenteditable]
value = instance.find_elements( { :css => params[:css] } )[0].text
if value != params[:value]
instance.execute_script( "$('#{params[:css]}').focus().html('#{params[:value]}').trigger('focusout')" )
end
end
sleep 0.5 sleep 0.5
end end
@ -402,6 +406,7 @@ class TestCase < Test::Unit::TestCase
end end
# match on attribute # match on attribute
begin
if params[:attribute] if params[:attribute]
text = element.attribute( params[:attribute] ) text = element.attribute( params[:attribute] )
elsif params[:css] =~ /(input|textarea)/i elsif params[:css] =~ /(input|textarea)/i
@ -409,6 +414,18 @@ class TestCase < Test::Unit::TestCase
else else
text = element.text text = element.text
end end
rescue
# just try again
element = instance.find_elements( { :css => params[:css] } )[0]
if params[:attribute]
text = element.attribute( params[:attribute] )
elsif params[:css] =~ /(input|textarea)/i
text = element.attribute('value')
else
text = element.text
end
end
match = false match = false
if params[:no_quote] if params[:no_quote]
#puts "aaaa #{text}/#{params[:value]}" #puts "aaaa #{text}/#{params[:value]}"
@ -430,7 +447,7 @@ class TestCase < Test::Unit::TestCase
end end
end end
sleep 0.8 sleep 0.8
return match match
end end
=begin =begin
@ -505,11 +522,35 @@ class TestCase < Test::Unit::TestCase
raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'" raise "not matching name '#{params[:name]}' in cookie '#{cookies.to_s}'"
end end
=begin
file_upload(
:browser => browser1,
:css => '#content .text-1',
:value => 'some text',
)
=end
def file_upload(params = {})
instance = params[:browser] || @browser
filename = 'some-file.txt'
file = File.join(Dir.pwd, filename)
#file = 'some test lalal'
element = instance.find_elements( { :css => params[:css] } )[0].send_keys file
#instance.find_elements( { :css => params[:css] } )[0]
#element
#@driver.find_element(id: 'file-submit').click
end
=begin =begin
watch_for( watch_for(
:browser => browser1, :browser => browser1,
:css => true, :css => '#content .text-1',
:value => 'some text', :value => 'some text',
:attribute => 'some_attribute' # optional :attribute => 'some_attribute' # optional
:timeout => '16', # in sec, default 16 :timeout => '16', # in sec, default 16
@ -557,7 +598,7 @@ class TestCase < Test::Unit::TestCase
watch_for_disappear( watch_for_disappear(
:browser => browser1, :browser => browser1,
:css => true, :css => '#content .text-1',
:timeout => '16', # in sec, default 16 :timeout => '16', # in sec, default 16
) )
@ -646,6 +687,7 @@ class TestCase < Test::Unit::TestCase
instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click instance.find_elements( { :css => 'a[href="#manage"]' } )[0].click
instance.find_elements( { :css => 'a[href="#manage/overviews"]' } )[0].click instance.find_elements( { :css => 'a[href="#manage/overviews"]' } )[0].click
sleep 0.2
instance.find_elements( { :css => '#content a[data-type="new"]' } )[0].click instance.find_elements( { :css => '#content a[data-type="new"]' } )[0].click
sleep 2 sleep 2
@ -746,18 +788,43 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { :css => '.active .newTicket div[data-name=body]' } )[0] element = instance.find_elements( { :css => '.active .newTicket div[data-name=body]' } )[0]
element.clear element.clear
element.send_keys( data[:body] ) element.send_keys( data[:body] )
# it's not working stable via selenium, use js
value = instance.find_elements( { :css => '.content .newTicket div[data-name=body]' } )[0].text
puts "V #{value.inspect}"
if value != data[:body]
instance.execute_script( "$('.content.active div[data-name=body]').html('#{data[:body]}').trigger('focusout')" )
end
end end
if data[:customer] if data[:customer]
element = instance.find_elements( { :css => '.active .newTicket input[name="customer_id_completion"]' } )[0] element = instance.find_elements( { :css => '.active .newTicket input[name="customer_id_completion"]' } )[0]
element.click element.click
element.clear element.clear
# workaround, sometimes focus is not triggered
element.send_keys( data[:customer] ) element.send_keys( data[:customer] )
sleep 4 sleep 4
# 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
element.send_keys( :arrow_down ) element.send_keys( :arrow_down )
sleep 0.1 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
sleep 0.3 sleep 0.3
end end
#file_upload(
# :browser => instance,
# :css => '#content .text-1',
# :value => 'some text',
#)
if params[:do_not_submit] if params[:do_not_submit]
assert( true, "ticket created without submit" ) assert( true, "ticket created without submit" )
return return
@ -839,6 +906,14 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0] element = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0]
element.clear element.clear
element.send_keys( data[:body] ) element.send_keys( data[:body] )
# it's not working stable via selenium, use js
value = instance.find_elements( { :css => '.content.active div[data-name=body]' } )[0].text
puts "V #{value.inspect}"
if value != data[:body]
instance.execute_script( "$('.content.active div[data-name=body]').html('#{data[:body]}').trigger('focusout')" )
end
end end
if data[:group] if data[:group]
@ -917,7 +992,9 @@ class TestCase < Test::Unit::TestCase
if number !~ /#{params[:number]}/ if number !~ /#{params[:number]}/
raise "unable to search/find ticket #{params[:number]}!" raise "unable to search/find ticket #{params[:number]}!"
end end
sleep 1
assert( true, "ticket #{params[:number]} found" ) assert( true, "ticket #{params[:number]} found" )
true
end end
=begin =begin
@ -960,6 +1037,8 @@ class TestCase < Test::Unit::TestCase
if number !~ /#{params[:number]}/ if number !~ /#{params[:number]}/
raise "unable to search/find ticket #{params[:number]}!" raise "unable to search/find ticket #{params[:number]}!"
end end
sleep 1
true
end end
=begin =begin
@ -1031,6 +1110,7 @@ class TestCase < Test::Unit::TestCase
return return
end end
assert( true, "org #{params[:value]} found" ) assert( true, "org #{params[:value]} found" )
sleep 2
true true
end end
@ -1057,6 +1137,7 @@ class TestCase < Test::Unit::TestCase
raise "unable to search/find user #{params[:value]}!" raise "unable to search/find user #{params[:value]}!"
end end
assert( true, "user #{params[:term]} found" ) assert( true, "user #{params[:term]} found" )
sleep 2
true true
end end