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',
:value => 'Invitation sent',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'Invitation sent',
},
{
:execute => 'match',

View file

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

View file

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

View file

@ -68,28 +68,22 @@ class AuthCustomerTest < TestCase
:result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
},
{
:execute => 'reload',
:execute => 'reload',
},
{
:execute => 'wait',
:value => 3,
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
},
{
:execute => 'match',
:css => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
},
{
:execute => 'match',
:element => :cookie,
:value => 'expires=>nil',
:execute => 'match',
:element => :cookie,
:value => 'expires=>nil',
},
],
},
@ -162,18 +156,17 @@ class AuthCustomerTest < TestCase
:result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'nicole.braun@zammad.org',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'nicole.braun@zammad.org',
},
{
:execute => 'match',
:element => :cookie,
:value => 'expires=>.+?\d{4}.+?,',
:execute => 'match',
:element => :cookie,
:value => 'expires=>.+?\d{4}.+?,',
},
{
:execute => 'logout',
:execute => 'logout',
},
],
},

View file

@ -63,15 +63,14 @@ class AuthMasterTest < TestCase
# check action
{
:execute => 'check',
:css => '#login',
:result => false,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:execute => 'match',
:css => 'body',
:value => 'master@example',
:match_result => true,
:execute => 'watch_for',
:area => 'body',
:value => 'master@example',
},
],
},

View file

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

View file

@ -58,17 +58,16 @@ class MaintenanceMessageTest < TestCase
:match_result => false,
},
{
:where => :instance2,
:execute => 'check',
:css => '.modal-header',
:result => true,
:where => :instance2,
:execute => 'check',
:css => '.modal-header',
:result => true,
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:value => message,
:match_result => true,
:where => :instance2,
:execute => 'watch_for',
:area => 'body',
:value => message,
},
{
:where => :instance2,
@ -129,16 +128,15 @@ class MaintenanceMessageTest < TestCase
:result => false,
},
{
:where => :instance2,
:execute => 'match',
:css => 'body',
:value => message + ' #2',
:match_result => true,
:where => :instance2,
:execute => 'watch_for',
:area => 'body',
:value => message + ' #2',
},
{
:where => :instance2,
:execute => 'click',
:css => 'div.modal-header .close',
:where => :instance2,
:execute => 'click',
:css => 'div.modal-header .close',
},
{
:execute => 'wait',

View file

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

View file

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

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
login = instance.find_element( { :css => '#login' } )
if !login
assert( false, "(#{test[:name]}) no login box found!" )
return
end
assert( true, "(#{test[:name]}) logout" )
(1..6).each {|loop|
login = instance.find_element( { :css => '#login' } )
if login
assert( true, "(#{test[:name]}) logout" )
return
end
}
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" )
return
end
assert( true, "(#{test[:name]}) ticket created" )
(1..14).each {|loop|
if instance.current_url =~ /#{Regexp.quote('#ticket/zoom/')}/
assert( true, "(#{test[:name]}) ticket created" )
return
end
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