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
# 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"]' )
watch_for(

View file

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

View file

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

View file

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