Improved browser tests.

This commit is contained in:
Martin Edenhofer 2013-08-27 23:05:33 +02:00
parent 212db28e5c
commit d49607b5a1
10 changed files with 106 additions and 143 deletions

View file

@ -64,7 +64,6 @@ class AaaGettingStartedTest < TestCase
{
:name => 'getting started - agent 1',
:action => [
{
:execute => 'match',
:css => 'body',
@ -100,16 +99,9 @@ class AaaGettingStartedTest < TestCase
:result => '#getting_started',
},
{
:execute => 'wait',
:value => 2,
},
# check action
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'Invitation sent',
:match_result => true,
},
{
:execute => 'match',

View file

@ -58,13 +58,12 @@ class AgentTicketActionLevel1Test < TestCase
},
{
:execute => 'wait',
:value => 4,
:value => 2,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'some body 1234 äöüß',
:match_result => true,
},
{
:execute => 'click',

View file

@ -239,16 +239,11 @@ class AgentTicketActionsLevel2Test < TestCase
:execute => 'click',
:css => '.active button',
},
{
:execute => 'wait',
:value => 4,
},
{
:where => :instance1,
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'some update 4711',
:match_result => true,
},
# verify empty text in input body

View file

@ -68,23 +68,17 @@ class AuthCustomerTest < TestCase
:result => false,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
},
{
:execute => 'reload',
},
{
:execute => 'wait',
:value => 3,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
},
{
:execute => 'match',
@ -162,10 +156,9 @@ class AuthCustomerTest < TestCase
:result => false,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
},
{
:execute => 'match',

View file

@ -68,10 +68,9 @@ class AuthMasterTest < TestCase
:result => false,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'master@example',
:match_result => true,
},
],
},

View file

@ -74,14 +74,9 @@ class CustomerTicketCreateTest < TestCase
:type => 'submit',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'some body 1234 äöüß',
:match_result => true,
},
],
},

View file

@ -65,10 +65,9 @@ class MaintenanceMessageTest < TestCase
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => message,
:match_result => true,
},
{
:where => :instance2,
@ -130,10 +129,9 @@ class MaintenanceMessageTest < TestCase
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => message + ' #2',
:match_result => true,
},
{
:where => :instance2,

View file

@ -70,14 +70,9 @@ class ManageTest < TestCase
:css => '.modal button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => random,
:match_result => true,
},
{
:execute => 'click',
@ -97,14 +92,9 @@ class ManageTest < TestCase
:css => '.modal button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => '2Manage Lastname' + random,
:match_result => true,
},
{
:execute => 'wait',
@ -150,14 +140,9 @@ class ManageTest < TestCase
:css => '.modal button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => random,
:match_result => true,
},
{
:execute => 'click',
@ -182,14 +167,9 @@ class ManageTest < TestCase
:css => '.modal button.submit',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'some sla update ' + random,
:match_result => true,
},
{
:execute => 'wait',

View file

@ -34,14 +34,9 @@ class PreferencesTest < TestCase
:css => '#language button',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'Sprache',
:match_result => true,
},
{
:execute => 'select',
@ -53,14 +48,9 @@ class PreferencesTest < TestCase
:css => '#language button',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'match',
:css => 'body',
:execute => 'watch_for',
:area => 'body',
:value => 'Language',
:match_result => true,
},
],
},

View file

@ -161,6 +161,13 @@ class TestCase < Test::Unit::TestCase
def browser_element_action(test, action, instance)
puts "NOTICE #{Time.now.to_s}: " + action.inspect
if action[:execute] !~ /accept|dismiss/i
cookies = instance.manage.all_cookies
cookies.each {|cookie|
puts " COOKIE " + cookie.to_s
}
end
sleep 0.1
if action[:css]
if action[:css].match '###stack###'
@ -228,13 +235,26 @@ class TestCase < Test::Unit::TestCase
instance.find_element( { :css => 'a[href="#current_user"]' } ).click
sleep 0.1
instance.find_element( { :css => 'a[href="#logout"]' } ).click
sleep 2
(1..6).each {|loop|
login = instance.find_element( { :css => '#login' } )
if !login
assert( false, "(#{test[:name]}) no login box found!" )
if login
assert( true, "(#{test[:name]}) logout" )
return
end
assert( true, "(#{test[:name]}) logout" )
}
assert( false, "(#{test[:name]}) no login box found!" )
return
elsif action[:execute] == 'watch_for'
(1..24).each { |loop|
element = instance.find_element( { :css => action[:area] } )
text = element.text
if text =~ /#{action[:value]}/i
assert( true, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
return
end
sleep 0.5
}
assert( false, "(#{test[:name]}) '#{action[:value]}' found in '#{text}'" )
return
elsif action[:execute] == 'create_ticket'
instance.find_element( { :css => 'a[href="#new"]' } ).click
@ -244,7 +264,7 @@ class TestCase < Test::Unit::TestCase
assert( false, "(#{test[:name]}) no ticket create screen found!" )
return
end
sleep 4
sleep 2
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
element.clear
element.send_keys( 'nico' )
@ -272,12 +292,14 @@ class TestCase < Test::Unit::TestCase
end
sleep 0.1
instance.find_element( { :css => '.active .form-actions button[type="submit"]' } ).click
sleep 6
if instance.current_url !~ /#{Regexp.quote('#ticket/zoom/')}/
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
(1..14).each {|loop|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
assert( true, "(#{test[:name]}) ticket created" )
return
end
assert( true, "(#{test[:name]}) ticket created" )
sleep 0.5
}
assert( true, "(#{test[:name]}) ticket creation failed, can't get zoom url" )
return
elsif action[:execute] == 'close_all_tasks'
for i in 1..100