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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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