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', :execute => 'close_all_tasks',
}, },
# create ticket
{ {
:execute => 'click', :execute => 'create_ticket',
:css => 'a[href="#new"]', :group => 'Users',
}, :subject => 'some subject 123äöü',
{ :body => 'some body 123äöü',
: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/',
}, },
# check ticket # check ticket
@ -136,73 +76,13 @@ class AgentTicketActionLevel1Test < TestCase
{ {
:name => 'agent ticket create 2', :name => 'agent ticket create 2',
:action => [ :action => [
# create ticket
{ {
:execute => 'click', :execute => 'create_ticket',
:css => 'a[href="#new"]', :group => 'Users',
}, :subject => 'test to merge',
{ :body => 'some body 123äöü 222',
: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/',
}, },
# check ticket # check ticket

View file

@ -27,84 +27,10 @@ class AgentTicketActionsLevel2Test < TestCase
# create ticket # create ticket
{ {
:where => :instance1, :where => :instance1,
:execute => 'click', :execute => 'create_ticket',
:css => 'a[href="#new"]', :group => 'Users',
}, :subject => 'some level 2 <b>subject</b> 123äöü',
{ :body => 'some level 2 <b>body</b> 123äöü',
: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/',
}, },
# check ticket # check ticket
@ -218,10 +144,9 @@ class AgentTicketActionsLevel2Test < TestCase
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 1, :value => 3,
}, },
# set body in edit area # set body in edit area
{ {
:where => :instance2, :where => :instance2,

View file

@ -27,78 +27,10 @@ class AgentTicketActionsLevel3Test < TestCase
# create ticket # create ticket
{ {
:where => :instance1, :where => :instance1,
:execute => 'click', :execute => 'create_ticket',
:css => 'a[href="#new"]', :group => 'Users',
}, :subject => 'some level 3 <b>subject</b> 123äöü',
{ :body => 'some level 3 <b>body</b> 123äöü',
: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/',
}, },
# check ticket # check ticket

View file

@ -10,67 +10,21 @@ class AgentTicketActionLevel4Test < TestCase
{ {
:execute => 'close_all_tasks', :execute => 'close_all_tasks',
}, },
# create ticket
{ {
:execute => 'click', :execute => 'create_ticket',
:css => 'a[href="#new"]', :group => 'Users',
}, :subject => 'some subject 4 - 123äöü',
{ :body => 'some body 4 - 123äöü',
:execute => 'click', :do_not_submit => true,
:css => 'a[href="#ticket_create/call_inbound"]',
}, },
{ {
:execute => 'wait', :execute => 'wait',
:value => 5, :value => 6,
},
{
: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,
}, },
# reload instances, verify again # reload instances, verify autosave
{ {
:execute => 'reload', :execute => 'reload',
}, },

View file

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

View file

@ -5,7 +5,7 @@ class TaskbarSessionTest < TestCase
def test_current_session_a_same_agent def test_current_session_a_same_agent
tests = [ tests = [
{ {
:name => 'start', :name => 'check taken over session block screen with same user',
:instance1 => browser_instance, :instance1 => browser_instance,
:instance2 => browser_instance, :instance2 => browser_instance,
:instance1_username => 'agent1@example.com', :instance1_username => 'agent1@example.com',
@ -41,7 +41,7 @@ class TaskbarSessionTest < TestCase
def test_current_session_b_different_agent def test_current_session_b_different_agent
tests = [ tests = [
{ {
:name => 'start', :name => 'check taken over session block screen with same user',
:instance1 => browser_instance, :instance1 => browser_instance,
:instance2 => browser_instance, :instance2 => browser_instance,
:instance1_username => 'master@example.com', :instance1_username => 'master@example.com',

View file

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

View file

@ -30,7 +30,12 @@ class TestCase < Test::Unit::TestCase
return local_browser return local_browser
end 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.platform = ENV['BROWSER_OS'] || 'Windows 2008'
caps.version = ENV['BROWSER_VERSION'] || '8' caps.version = ENV['BROWSER_VERSION'] || '8'
local_browser = Selenium::WebDriver.for( local_browser = Selenium::WebDriver.for(
@ -70,36 +75,9 @@ class TestCase < Test::Unit::TestCase
:url => data[:url] || browser_url, :url => data[:url] || browser_url,
:action => [ :action => [
{ {
:execute => 'wait', :execute => 'login',
:value => 2, :username => data[:username] || 'nicole.braun@zammad.org',
}, :password => data[:password] || 'test'
{
: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,
}, },
], ],
}, },
@ -175,8 +153,8 @@ class TestCase < Test::Unit::TestCase
end end
def browser_element_action(test, action, instance) def browser_element_action(test, action, instance)
puts "NOTICE: " + action.inspect puts "NOTICE #{Time.now.to_s}: " + action.inspect
sleep 0.2 sleep 0.1
if action[:css] if action[:css]
if action[:css].match '###stack###' if action[:css].match '###stack###'
action[:css].gsub! '###stack###', @stack action[:css].gsub! '###stack###', @stack
@ -225,8 +203,79 @@ puts "NOTICE: " + action.inspect
return return
elsif action[:element] == :alert elsif action[:element] == :alert
element = instance.switch_to.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' elsif action[:execute] == 'close_all_tasks'
# while true
for i in 1..100 for i in 1..100
begin begin
element = instance.find_element( { :css => '.taskbar [data-type="close"]' } ) element = instance.find_element( { :css => '.taskbar [data-type="close"]' } )
@ -240,10 +289,14 @@ puts "NOTICE: " + action.inspect
break break
end end
end end
assert( true, "(#{test[:name]}) all tasks closed" )
return
elsif action[:execute] == 'navigate' elsif action[:execute] == 'navigate'
instance.navigate.to( action[:to] ) instance.navigate.to( action[:to] )
return
elsif action[:execute] == 'reload' elsif action[:execute] == 'reload'
instance.navigate.refresh instance.navigate.refresh
return
elsif action[:execute] == 'js' elsif action[:execute] == 'js'
result = instance.execute_script( action[:value] ) result = instance.execute_script( action[:value] )
elsif action[:link] elsif action[:link]
@ -351,9 +404,6 @@ puts "NOTICE: " + action.inspect
end end
end end
elsif action[:execute] == 'check' elsif action[:execute] == 'check'
elsif action[:execute] == 'close_all_tasks'
elsif action[:execute] == 'navigate'
elsif action[:execute] == 'reload'
elsif action[:execute] == 'js' elsif action[:execute] == 'js'
else else
assert( false, "(#{test[:name]}) unknow action '#{action[:execute]}'" ) assert( false, "(#{test[:name]}) unknow action '#{action[:execute]}'" )