Added screenshot support.
This commit is contained in:
parent
7ecb82c324
commit
7863118515
1 changed files with 41 additions and 0 deletions
|
@ -69,10 +69,19 @@ class TestCase < Test::Unit::TestCase
|
||||||
def teardown
|
def teardown
|
||||||
return if !@browsers
|
return if !@browsers
|
||||||
@browsers.each { |hash, local_browser|
|
@browsers.each { |hash, local_browser|
|
||||||
|
screenshot( :browser => local_browser, :comment => 'teardown' )
|
||||||
browser_instance_close(local_browser)
|
browser_instance_close(local_browser)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def screenshot(params)
|
||||||
|
instance = params[:browser] || @browser
|
||||||
|
comment = params[:comment] || ''
|
||||||
|
filename = "tmp/#{Time.zone.now.strftime("screenshot_%Y_%m_%d__%H_%M_%S")}_#{comment}_#{instance.hash}.png"
|
||||||
|
log('screenshot', {:filename => filename})
|
||||||
|
instance.save_screenshot(filename)
|
||||||
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
username = login(
|
username = login(
|
||||||
|
@ -95,8 +104,12 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
element = instance.find_elements( { css: '#login input[name="username"]' } )[0]
|
element = instance.find_elements( { css: '#login input[name="username"]' } )[0]
|
||||||
if !element
|
if !element
|
||||||
|
screenshot( :browser => instance, :comment => 'login_failed' )
|
||||||
raise 'No login box found'
|
raise 'No login box found'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
screenshot( :browser => instance, :comment => 'login' )
|
||||||
|
|
||||||
element.clear
|
element.clear
|
||||||
element.send_keys( params[:username] )
|
element.send_keys( params[:username] )
|
||||||
|
|
||||||
|
@ -112,8 +125,10 @@ class TestCase < Test::Unit::TestCase
|
||||||
sleep 4
|
sleep 4
|
||||||
login = instance.find_elements( { css: '.user-menu .user a' } )[0].attribute('title')
|
login = instance.find_elements( { css: '.user-menu .user a' } )[0].attribute('title')
|
||||||
if login != params[:username]
|
if login != params[:username]
|
||||||
|
screenshot( :browser => instance, :comment => 'login_failed' )
|
||||||
raise 'login failed'
|
raise 'login failed'
|
||||||
end
|
end
|
||||||
|
screenshot( :browser => instance, :comment => 'login_ok' )
|
||||||
assert( true, 'login ok' )
|
assert( true, 'login ok' )
|
||||||
login
|
login
|
||||||
end
|
end
|
||||||
|
@ -138,10 +153,12 @@ class TestCase < Test::Unit::TestCase
|
||||||
sleep 1
|
sleep 1
|
||||||
login = instance.find_elements( { css: '#login' } )[0]
|
login = instance.find_elements( { css: '#login' } )[0]
|
||||||
if login
|
if login
|
||||||
|
screenshot( :browser => instance, :comment => 'logout_ok' )
|
||||||
assert( true, 'logout ok' )
|
assert( true, 'logout ok' )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'logout_failed' )
|
||||||
raise 'no login box found, seems logout was not successfully!'
|
raise 'no login box found, seems logout was not successfully!'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,6 +176,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
instance.get( params[:url] )
|
instance.get( params[:url] )
|
||||||
|
screenshot( :browser => instance, :comment => 'location' )
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -175,6 +193,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
if instance.current_url !~ /#{Regexp.quote(params[:url])}/
|
if instance.current_url !~ /#{Regexp.quote(params[:url])}/
|
||||||
|
screenshot( :browser => instance, :comment => 'location_check_failed' )
|
||||||
raise "url #{instance.current_url} is not matching #{params[:url]}"
|
raise "url #{instance.current_url} is not matching #{params[:url]}"
|
||||||
end
|
end
|
||||||
assert( true, "url #{instance.current_url} is matching #{params[:url]}" )
|
assert( true, "url #{instance.current_url} is matching #{params[:url]}" )
|
||||||
|
@ -192,7 +211,9 @@ class TestCase < Test::Unit::TestCase
|
||||||
log('reload', params)
|
log('reload', params)
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
|
screenshot( :browser => instance, :comment => 'reload_before' )
|
||||||
instance.navigate.refresh
|
instance.navigate.refresh
|
||||||
|
screenshot( :browser => instance, :comment => 'reload_after' )
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -237,6 +258,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
if !instance.find_elements( { css: params[:css] } )[0]
|
if !instance.find_elements( { css: params[:css] } )[0]
|
||||||
|
screenshot( :browser => instance, :comment => 'exists_failed' )
|
||||||
raise "#{params[:css]} dosn't exist, but should"
|
raise "#{params[:css]} dosn't exist, but should"
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
|
@ -256,6 +278,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
if instance.find_elements( { css: params[:css] } )[0]
|
if instance.find_elements( { css: params[:css] } )[0]
|
||||||
|
screenshot( :browser => instance, :comment => 'exists_not_failed' )
|
||||||
raise "#{params[:css]} exists but should not"
|
raise "#{params[:css]} exists but should not"
|
||||||
end
|
end
|
||||||
true
|
true
|
||||||
|
@ -681,6 +704,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
element = instance.find_elements( { partial_link_text: data[:title] } )[0]
|
element = instance.find_elements( { partial_link_text: data[:title] } )[0]
|
||||||
if !element
|
if !element
|
||||||
|
screenshot( :browser => instance, :comment => 'open_task_failed' )
|
||||||
raise "no task with title '#{data[:title]}' found"
|
raise "no task with title '#{data[:title]}' found"
|
||||||
end
|
end
|
||||||
element.click
|
element.click
|
||||||
|
@ -760,6 +784,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'watch_for_failed' )
|
||||||
raise "'#{params[:value]}' found in '#{text}'"
|
raise "'#{params[:value]}' found in '#{text}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -816,6 +841,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'disappear_failed' )
|
||||||
raise "#{params[:css]}) still exsists"
|
raise "#{params[:css]}) still exsists"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -928,6 +954,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'overview_create_failed' )
|
||||||
raise 'overview creation failed'
|
raise 'overview creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -962,6 +989,7 @@ wait untill text in selector disabppears
|
||||||
instance.find_elements( { css: 'a[href="#ticket/create"]' } )[0].click
|
instance.find_elements( { css: 'a[href="#ticket/create"]' } )[0].click
|
||||||
element = instance.find_elements( { css: '.active .newTicket' } )[0]
|
element = instance.find_elements( { css: '.active .newTicket' } )[0]
|
||||||
if !element
|
if !element
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_create_failed' )
|
||||||
raise 'no ticket create screen found!'
|
raise 'no ticket create screen found!'
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -1051,11 +1079,13 @@ wait untill text in selector disabppears
|
||||||
number: number,
|
number: number,
|
||||||
}
|
}
|
||||||
sleep 3 # wait until notify is gone
|
sleep 3 # wait until notify is gone
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_create_ok' )
|
||||||
return ticket
|
return ticket
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_create_failed' )
|
||||||
raise "ticket creation failed, can't get zoom url (current url is '#{ instance.current_url }')"
|
raise "ticket creation failed, can't get zoom url (current url is '#{ instance.current_url }')"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1204,6 +1234,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
if !found
|
if !found
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_update_discard_message_failed' )
|
||||||
raise 'no discard message found'
|
raise 'no discard message found'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1219,6 +1250,7 @@ wait untill text in selector disabppears
|
||||||
begin
|
begin
|
||||||
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
text = instance.find_elements( { css: '.content.active .js-reset' } )[0].text
|
||||||
if !text || text.empty?
|
if !text || text.empty?
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_update_ok' )
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
|
@ -1226,6 +1258,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_update_failed' )
|
||||||
raise 'unable to update ticket'
|
raise 'unable to update ticket'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1292,6 +1325,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
|
number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
|
||||||
if number !~ /#{params[:number]}/
|
if number !~ /#{params[:number]}/
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_open_by_overview_failed' )
|
||||||
raise "unable to search/find ticket #{params[:number]}!"
|
raise "unable to search/find ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -1339,6 +1373,7 @@ wait untill text in selector disabppears
|
||||||
instance.find_element( { partial_link_text: params[:number] } ).click
|
instance.find_element( { partial_link_text: params[:number] } ).click
|
||||||
number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
|
number = instance.find_elements( { css: '.active .page-header .ticket-number' } )[0].text
|
||||||
if number !~ /#{params[:number]}/
|
if number !~ /#{params[:number]}/
|
||||||
|
screenshot( :browser => instance, :comment => 'ticket_open_by_search_failed' )
|
||||||
raise "unable to search/find ticket #{params[:number]}!"
|
raise "unable to search/find ticket #{params[:number]}!"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -1414,6 +1449,7 @@ wait untill text in selector disabppears
|
||||||
instance.find_element( { partial_link_text: params[:value] } ).click
|
instance.find_element( { partial_link_text: params[:value] } ).click
|
||||||
name = instance.find_elements( { css: '.active h1' } )[0].text
|
name = instance.find_elements( { css: '.active h1' } )[0].text
|
||||||
if name !~ /#{params[:value]}/
|
if name !~ /#{params[:value]}/
|
||||||
|
screenshot( :browser => instance, :comment => 'organization_open_by_search_failed' )
|
||||||
raise "unable to search/find org #{params[:value]}!"
|
raise "unable to search/find org #{params[:value]}!"
|
||||||
end
|
end
|
||||||
assert( true, "org #{params[:value]} found" )
|
assert( true, "org #{params[:value]} found" )
|
||||||
|
@ -1443,6 +1479,7 @@ wait untill text in selector disabppears
|
||||||
instance.find_element( { partial_link_text: params[:value] } ).click
|
instance.find_element( { partial_link_text: params[:value] } ).click
|
||||||
name = instance.find_elements( { css: '.active h1' } )[0].text
|
name = instance.find_elements( { css: '.active h1' } )[0].text
|
||||||
if name !~ /#{params[:value]}/
|
if name !~ /#{params[:value]}/
|
||||||
|
screenshot( :browser => instance, :comment => 'user_open_by_search_failed' )
|
||||||
raise "unable to search/find user #{params[:value]}!"
|
raise "unable to search/find user #{params[:value]}!"
|
||||||
end
|
end
|
||||||
assert( true, "user #{params[:term]} found" )
|
assert( true, "user #{params[:term]} found" )
|
||||||
|
@ -1548,6 +1585,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'sla_create_failed' )
|
||||||
raise 'sla creation failed'
|
raise 'sla creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1594,6 +1632,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'text_module_create_failed' )
|
||||||
raise 'text module creation failed'
|
raise 'text module creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1637,6 +1676,7 @@ wait untill text in selector disabppears
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'signature_create_failed' )
|
||||||
raise 'signature creation failed'
|
raise 'signature creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1707,6 +1747,7 @@ wait untill text in selector disabppears
|
||||||
sleep 1
|
sleep 1
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
screenshot( :browser => instance, :comment => 'group_create_failed' )
|
||||||
raise 'group creation failed'
|
raise 'group creation failed'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue