Selenium adjustments.

This commit is contained in:
Martin Edenhofer 2013-07-25 11:11:20 +02:00
parent 07bd230320
commit aea5dd643a
8 changed files with 152 additions and 394 deletions

View file

@ -10,73 +10,13 @@ class AgentTicketActionLevel1Test < TestCase
{
:execute => 'close_all_tasks',
},
# create ticket
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.active .ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'some subject 123äöü',
},
{
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'some body 123äöü',
},
{
:execute => 'click',
:css => '.active .form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some subject 123äöü',
:body => 'some body 123äöü',
},
# check ticket
@ -136,73 +76,13 @@ class AgentTicketActionLevel1Test < TestCase
{
:name => 'agent ticket create 2',
:action => [
# create ticket
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.active .ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'test to merge',
},
{
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'some body 123äöü 222',
},
{
:execute => 'click',
:css => '.active .form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
{
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
:execute => 'create_ticket',
:group => 'Users',
:subject => 'test to merge',
:body => 'some body 123äöü 222',
},
# check ticket

View file

@ -27,84 +27,10 @@ class AgentTicketActionsLevel2Test < TestCase
# create ticket
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:where => :instance1,
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:where => :instance1,
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:where => :instance1,
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:where => :instance1,
:execute => 'select',
:css => '.active .ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'some level 2 <b>subject</b> 123äöü',
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'some level 2 <b>body</b> 123äöü',
},
{
:where => :instance1,
:execute => 'click',
:css => '.active .form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:where => :instance1,
:execute => 'check',
:css => '#login',
:result => false,
},
{
:where => :instance1,
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some level 2 <b>subject</b> 123äöü',
:body => 'some level 2 <b>body</b> 123äöü',
},
# check ticket
@ -118,7 +44,7 @@ class AgentTicketActionsLevel2Test < TestCase
# remember old ticket where we want to merge to
{
:where => :instance1,
:where => :instance1,
:execute => 'match',
:css => '.active .ticket-zoom small',
:value => '^(.*)$',
@ -218,10 +144,9 @@ class AgentTicketActionsLevel2Test < TestCase
},
{
:execute => 'wait',
:value => 1,
:value => 3,
},
# set body in edit area
{
:where => :instance2,

View file

@ -27,78 +27,10 @@ class AgentTicketActionsLevel3Test < TestCase
# create ticket
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:where => :instance1,
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
},
{
:execute => 'wait',
:value => 5,
},
{
:where => :instance1,
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:where => :instance1,
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:where => :instance1,
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:where => :instance1,
:execute => 'select',
:css => '.active .ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'some level 3 <b>subject</b> 123äöü',
},
{
:where => :instance1,
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'some level 3 <b>body</b> 123äöü',
},
{
:where => :instance1,
:execute => 'click',
:css => '.active .form-actions button[type="submit"]',
},
{
:execute => 'wait',
:value => 6,
},
{
:where => :instance1,
:execute => 'check',
:element => :url,
:result => '#ticket/zoom/',
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some level 3 <b>subject</b> 123äöü',
:body => 'some level 3 <b>body</b> 123äöü',
},
# check ticket

View file

@ -10,67 +10,21 @@ class AgentTicketActionLevel4Test < TestCase
{
:execute => 'close_all_tasks',
},
# create ticket
{
:execute => 'click',
:css => 'a[href="#new"]',
},
{
:execute => 'click',
:css => 'a[href="#ticket_create/call_inbound"]',
:execute => 'create_ticket',
:group => 'Users',
:subject => 'some subject 4 - 123äöü',
:body => 'some body 4 - 123äöü',
:do_not_submit => true,
},
{
:execute => 'wait',
:value => 5,
},
{
:execute => 'check',
:css => '.active .ticket_create',
:result => true,
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => 'ma',
},
{
:execute => 'wait',
:value => 4,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :arrow_down,
},
{
:execute => 'sendkey',
:css => '.active .ticket_create input[name="customer_id_autocompletion"]',
:value => :tab,
},
{
:execute => 'select',
:css => '.active .ticket_create select[name="group_id"]',
:value => 'Users',
},
{
:execute => 'set',
:css => '.active .ticket_create input[name="subject"]',
:value => 'some subject 4 - 123äöü',
},
{
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'some body 4 - 123äöü',
},
{
:execute => 'wait',
:value => 7,
:value => 6,
},
# reload instances, verify again
# reload instances, verify autosave
{
:execute => 'reload',
},

View file

@ -176,6 +176,9 @@ class AuthTest < TestCase
:element => :cookie,
:value => 'expires=>.+?\d{4}.+?,',
},
{
:execute => 'logout',
},
],
},
]

View file

@ -5,13 +5,13 @@ class TaskbarSessionTest < TestCase
def test_current_session_a_same_agent
tests = [
{
:name => 'start',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'agent1@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:name => 'check taken over session block screen with same user',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'agent1@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url,
:action => [
{
@ -41,14 +41,14 @@ class TaskbarSessionTest < TestCase
def test_current_session_b_different_agent
tests = [
{
:name => 'start',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url,
:name => 'check taken over session block screen with same user',
:instance1 => browser_instance,
:instance2 => browser_instance,
:instance1_username => 'master@example.com',
:instance1_password => 'test',
:instance2_username => 'agent1@example.com',
:instance2_password => 'test',
:url => browser_url,
:action => [
{
:execute => 'wait',

View file

@ -118,7 +118,12 @@ class TaskbarTaskTest < TestCase
},
{
:execute => 'wait',
:value => 3,
:value => 4,
},
{
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'INBOUND BODY TEST#1',
},
{
:execute => 'click',
@ -137,6 +142,15 @@ class TaskbarTaskTest < TestCase
:css => '.active .ticket_create input[name="subject"]',
:value => 'OUTBOUND TEST#1',
},
{
:execute => 'wait',
:value => 1,
},
{
:execute => 'set',
:css => '.active .ticket_create textarea[name="body"]',
:value => 'OUTBOUND BODY TEST#1',
},
{
:execute => 'wait',
:value => 12,

View file

@ -30,7 +30,12 @@ class TestCase < Test::Unit::TestCase
return local_browser
end
caps = Selenium::WebDriver::Remote::Capabilities.send( browser )
caps = Selenium::WebDriver::Remote::Capabilities.send(
browser,
#:forceCreateProcess => true,
#:ensureCleanSession => true,
#:internetExplorerSwitches => 'InetCpl.cpl,ClearMyTracksByProcess 2',
)
caps.platform = ENV['BROWSER_OS'] || 'Windows 2008'
caps.version = ENV['BROWSER_VERSION'] || '8'
local_browser = Selenium::WebDriver.for(
@ -70,36 +75,9 @@ class TestCase < Test::Unit::TestCase
:url => data[:url] || browser_url,
:action => [
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'check',
:css => '#login',
:result => true,
},
{
:execute => 'set',
:css => 'input[name="username"]',
:value => data[:username] || 'nicole.braun@zammad.org',
},
{
:execute => 'set',
:css => 'input[name="password"]',
:value => data[:password] || 'test'
},
{
:execute => 'click',
:css => '#login button',
},
{
:execute => 'wait',
:value => 2,
},
{
:execute => 'check',
:css => '#login',
:result => false,
:execute => 'login',
:username => data[:username] || 'nicole.braun@zammad.org',
:password => data[:password] || 'test'
},
],
},
@ -175,8 +153,8 @@ class TestCase < Test::Unit::TestCase
end
def browser_element_action(test, action, instance)
puts "NOTICE: " + action.inspect
sleep 0.2
puts "NOTICE #{Time.now.to_s}: " + action.inspect
sleep 0.1
if action[:css]
if action[:css].match '###stack###'
action[:css].gsub! '###stack###', @stack
@ -225,9 +203,80 @@ puts "NOTICE: " + action.inspect
return
elsif action[:element] == :alert
element = instance.switch_to.alert
elsif action[:execute] == 'login'
sleep 1
login = instance.find_element( { :css => '#login' } )
if !login
assert( false, "(#{test[:name]}) no login box found!" )
return
end
element = instance.find_element( { :css => '#login input[name="username"]' } )
element.clear
element.send_keys( action[:username] )
element = instance.find_element( { :css => '#login input[name="password"]' } )
element.clear
element.send_keys( action[:password] )
instance.find_element( { :css => '#login button' } ).click
sleep 4
return
elsif action[:execute] == 'logout'
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" )
return
elsif action[:execute] == 'create_ticket'
instance.find_element( { :css => 'a[href="#new"]' } ).click
instance.find_element( { :css => 'a[href="#ticket_create/call_inbound"]' } ).click
sleep 4
element = instance.find_element( { :css => '.active .ticket_create' } )
if !element
assert( false, "(#{test[:name]}) no ticket create screen found!" )
return
end
sleep 5
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
element.clear
element.send_keys( 'ma' )
sleep 4
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
element.send_keys( :arrow_down )
sleep 0.2
element = instance.find_element( { :css => '.active .ticket_create input[name="customer_id_autocompletion"]' } )
element.send_keys( :tab )
sleep 0.1
element = instance.find_element( { :css => '.active .ticket_create select[name="group_id"]' } )
dropdown = Selenium::WebDriver::Support::Select.new(element)
dropdown.select_by( :text, action[:group])
sleep 0.1
element = instance.find_element( { :css => '.active .ticket_create input[name="subject"]' } )
element.clear
element.send_keys( action[:subject] )
sleep 0.1
element = instance.find_element( { :css => '.active .ticket_create textarea[name="body"]' } )
element.clear
element.send_keys( action[:body] )
if action[:do_not_submit]
assert( true, "(#{test[:name]}) ticket created without submit" )
return
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" )
return
elsif action[:execute] == 'close_all_tasks'
# while true
for i in 1..100
for i in 1..100
begin
element = instance.find_element( { :css => '.taskbar [data-type="close"]' } )
if element
@ -240,10 +289,14 @@ puts "NOTICE: " + action.inspect
break
end
end
assert( true, "(#{test[:name]}) all tasks closed" )
return
elsif action[:execute] == 'navigate'
instance.navigate.to( action[:to] )
return
elsif action[:execute] == 'reload'
instance.navigate.refresh
return
elsif action[:execute] == 'js'
result = instance.execute_script( action[:value] )
elsif action[:link]
@ -351,9 +404,6 @@ puts "NOTICE: " + action.inspect
end
end
elsif action[:execute] == 'check'
elsif action[:execute] == 'close_all_tasks'
elsif action[:execute] == 'navigate'
elsif action[:execute] == 'reload'
elsif action[:execute] == 'js'
else
assert( false, "(#{test[:name]}) unknow action '#{action[:execute]}'" )