Just create screenshots of failed selenium actions (increase speed of tests too).

This commit is contained in:
Martin Edenhofer 2018-05-22 00:58:50 +02:00
parent 5b0b10ce59
commit d2446531a1
2 changed files with 31 additions and 65 deletions

View file

@ -13,7 +13,11 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
click(css: 'a[href="#new"]', only_if_exists: true) click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]') click(css: 'a[href="#ticket/create"]')
sleep 2
watch_for(
css: '.content.active .newTicket',
timeout: 3,
)
exists(css: '.content.active .newTicket') exists(css: '.content.active .newTicket')
exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]') exists(css: '.content.active .tabsSidebar .sidebar[data-tab="template"]')
@ -31,8 +35,11 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .newTicket input[name="customer_id_completion"]', css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'nicole', value: 'nicole',
) )
watch_for(
sleep 2 css: '.content.active .newTicket .js-recipientDropdown .recipientList.is-shown',
value: 'Nicole',
timeout: 3,
)
sendkey(value: :enter) sendkey(value: :enter)
sleep 1 sleep 1
@ -48,7 +55,6 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
value: '', value: '',
) )
sendkey(value: :backspace) sendkey(value: :backspace)
sleep 1 sleep 1
exists(css: '.content.active .newTicket') exists(css: '.content.active .newTicket')
@ -62,17 +68,14 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .newTicket input[name="title"]', css: '.content.active .newTicket input[name="title"]',
value: 'some title', value: 'some title',
) )
set( set(
css: '.content.active .newTicket div[data-name="body"]', css: '.content.active .newTicket div[data-name="body"]',
value: 'some body', value: 'some body',
) )
select( select(
css: '.content.active .newTicket select[name="group_id"]', css: '.content.active .newTicket select[name="group_id"]',
value: 'Users', value: 'Users',
) )
click(css: '.content.active .newTicket .js-submit') click(css: '.content.active .newTicket .js-submit')
watch_for( watch_for(
@ -112,8 +115,11 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .newTicket input[name="customer_id_completion"]', css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'nicole', value: 'nicole',
) )
watch_for(
sleep 2 css: '.content.active .newTicket .js-recipientDropdown .recipientList.is-shown',
value: 'Nicole',
timeout: 3,
)
sendkey(value: :enter) sendkey(value: :enter)
sleep 1 sleep 1
@ -129,7 +135,6 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
value: '', value: '',
) )
sendkey(value: :backspace) sendkey(value: :backspace)
sleep 1 sleep 1
exists(css: '.content.active .newTicket') exists(css: '.content.active .newTicket')
@ -143,22 +148,18 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .newTicket input[name="customer_id_completion"]', css: '.content.active .newTicket input[name="customer_id_completion"]',
value: 'somecustomer_not_existing_right_now@example.com', value: 'somecustomer_not_existing_right_now@example.com',
) )
set( set(
css: '.content.active .newTicket input[name="title"]', css: '.content.active .newTicket input[name="title"]',
value: 'some title', value: 'some title',
) )
set( set(
css: '.content.active .newTicket div[data-name="body"]', css: '.content.active .newTicket div[data-name="body"]',
value: 'some body', value: 'some body',
) )
select( select(
css: '.content.active .newTicket select[name="group_id"]', css: '.content.active .newTicket select[name="group_id"]',
value: 'Users', value: 'Users',
) )
click(css: '.content.active .newTicket .js-submit') click(css: '.content.active .newTicket .js-submit')
watch_for( watch_for(
@ -194,7 +195,6 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .modal input[name="customer_id_completion"]', css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master', value: 'master',
) )
click(css: '.content.active .modal .js-submit') click(css: '.content.active .modal .js-submit')
watch_for( watch_for(
@ -205,7 +205,11 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .modal input[name="customer_id_completion"]', css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master', value: 'master',
) )
watch_for(
css: '.content.active .modal .js-recipientDropdown .recipientList.is-shown',
value: 'Master',
timeout: 3,
)
sendkey(value: :enter) sendkey(value: :enter)
sleep 1 sleep 1
@ -226,7 +230,11 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
css: '.content.active .modal input[name="customer_id_completion"]', css: '.content.active .modal input[name="customer_id_completion"]',
value: 'master', value: 'master',
) )
watch_for(
css: '.content.active .modal .js-recipientDropdown .recipientList.is-shown',
value: 'Master',
timeout: 3,
)
sendkey(value: :enter) sendkey(value: :enter)
sleep 1 sleep 1

View file

@ -186,8 +186,6 @@ class TestCase < Test::Unit::TestCase
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])
@ -228,7 +226,6 @@ class TestCase < Test::Unit::TestCase
optional: true, optional: true,
) )
screenshot(browser: instance, comment: 'login_ok')
assert(true, 'login ok') assert(true, 'login ok')
login login
end end
@ -263,7 +260,6 @@ class TestCase < Test::Unit::TestCase
login = instance.find_elements(css: '#login')[0] login = instance.find_elements(css: '#login')[0]
next if !login next if !login
screenshot(browser: instance, comment: 'logout_ok')
assert(true, 'logout ok') assert(true, 'logout ok')
return return
end end
@ -343,7 +339,6 @@ class TestCase < Test::Unit::TestCase
if !instance.find_elements(css: 'body')[0] || instance.find_elements(css: 'body')[0].text =~ /unavailable or too busy/i if !instance.find_elements(css: 'body')[0] || instance.find_elements(css: 'body')[0].text =~ /unavailable or too busy/i
instance.navigate.refresh instance.navigate.refresh
end end
screenshot(browser: instance, comment: 'location')
end end
=begin =begin
@ -382,7 +377,6 @@ 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
# check if reload was successfull # check if reload was successfull
@ -415,7 +409,6 @@ class TestCase < Test::Unit::TestCase
log('click', params) log('click', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'click_before')
if params[:css] if params[:css]
begin begin
@ -477,7 +470,6 @@ class TestCase < Test::Unit::TestCase
if params[:position] == 'botton' if params[:position] == 'botton'
position = 'false' position = 'false'
end end
screenshot(browser: instance, comment: 'scroll_to_before')
execute( execute(
browser: instance, browser: instance,
js: "\$('#{params[:css]}').get(0).scrollIntoView(#{position})", js: "\$('#{params[:css]}').get(0).scrollIntoView(#{position})",
@ -520,10 +512,7 @@ class TestCase < Test::Unit::TestCase
log('modal_ready', params) log('modal_ready', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'modal_ready_before')
sleep 3 sleep 3
screenshot(browser: instance, comment: 'modal_ready_after')
end end
=begin =begin
@ -541,13 +530,11 @@ class TestCase < Test::Unit::TestCase
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'modal_disappear_before')
watch_for_disappear( watch_for_disappear(
browser: instance, browser: instance,
css: '.modal', css: '.modal',
timeout: params[:timeout] || 8, timeout: params[:timeout] || 8,
) )
screenshot(browser: instance, comment: 'modal_disappear_after')
end end
=begin =begin
@ -647,7 +634,6 @@ class TestCase < Test::Unit::TestCase
log('set', params) log('set', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'set_before')
element = instance.find_elements(css: params[:css])[0] element = instance.find_elements(css: params[:css])[0]
if !params[:no_click] if !params[:no_click]
@ -694,7 +680,6 @@ class TestCase < Test::Unit::TestCase
end end
sleep 0.2 sleep 0.2
screenshot(browser: instance, comment: 'set_after')
end end
=begin =begin
@ -713,7 +698,6 @@ class TestCase < Test::Unit::TestCase
log('select', params) log('select', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'select_before')
# searchable select # searchable select
element = instance.find_elements(css: "#{params[:css]}.js-shadow")[0] element = instance.find_elements(css: "#{params[:css]}.js-shadow")[0]
@ -721,7 +705,7 @@ class TestCase < Test::Unit::TestCase
element = instance.find_elements(css: "#{params[:css]}.js-shadow + .js-input")[0] element = instance.find_elements(css: "#{params[:css]}.js-shadow + .js-input")[0]
element.click element.click
element.clear element.clear
sleep 0.4 sleep 0.2
element.send_keys(params[:value]) element.send_keys(params[:value])
sleep 0.2 sleep 0.2
element.send_keys(:enter) element.send_keys(:enter)
@ -751,8 +735,6 @@ class TestCase < Test::Unit::TestCase
dropdown.select_by(:text, params[:value]) dropdown.select_by(:text, params[:value])
#puts "select2 - #{params.inspect}" #puts "select2 - #{params.inspect}"
end end
sleep 0.4
screenshot(browser: instance, comment: 'select_after')
end end
=begin =begin
@ -771,7 +753,6 @@ class TestCase < Test::Unit::TestCase
log('switch', params) log('switch', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'switch_before')
element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0] element = instance.find_elements(css: "#{params[:css]} input[type=checkbox]")[0]
checked = element.attribute('checked') checked = element.attribute('checked')
@ -797,7 +778,6 @@ class TestCase < Test::Unit::TestCase
raise 'Switch not off!' if checked raise 'Switch not off!' if checked
end end
end end
screenshot(browser: instance, comment: 'switch_after')
end end
=begin =begin
@ -814,13 +794,11 @@ class TestCase < Test::Unit::TestCase
log('check', params) log('check', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'check_before')
instance.execute_script("if (!$('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }") instance.execute_script("if (!$('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }")
#element = instance.find_elements(css: params[:css])[0] #element = instance.find_elements(css: params[:css])[0]
#checked = element.attribute('checked') #checked = element.attribute('checked')
#element.click if !checked #element.click if !checked
screenshot(browser: instance, comment: 'check_after')
end end
=begin =begin
@ -837,13 +815,11 @@ class TestCase < Test::Unit::TestCase
log('uncheck', params) log('uncheck', params)
instance = params[:browser] || @browser instance = params[:browser] || @browser
screenshot(browser: instance, comment: 'uncheck_before')
instance.execute_script("if ($('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }") instance.execute_script("if ($('#{params[:css]}').prop('checked')) { $('#{params[:css]}').click() }")
#element = instance.find_elements(css: params[:css])[0] #element = instance.find_elements(css: params[:css])[0]
#checked = element.attribute('checked') #checked = element.attribute('checked')
#element.click if checked #element.click if checked
screenshot(browser: instance, comment: 'uncheck_after')
end end
=begin =begin
@ -865,7 +841,6 @@ class TestCase < Test::Unit::TestCase
if params[:css] if params[:css]
element = instance.find_elements(css: params[:css])[0] element = instance.find_elements(css: params[:css])[0]
end end
screenshot(browser: instance, comment: 'sendkey_before')
if params[:value].class == Array if params[:value].class == Array
params[:value].each do |key| params[:value].each do |key|
if element if element
@ -874,7 +849,6 @@ class TestCase < Test::Unit::TestCase
instance.action.send_keys(key).perform instance.action.send_keys(key).perform
end end
end end
screenshot(browser: instance, comment: 'sendkey_after')
return return
end end
@ -888,7 +862,6 @@ class TestCase < Test::Unit::TestCase
else else
sleep 0.2 sleep 0.2
end end
screenshot(browser: instance, comment: 'sendkey_after')
end end
=begin =begin
@ -1941,7 +1914,6 @@ wait untill text in selector disabppears
value: data[:group], value: data[:group],
mute_log: true, mute_log: true,
) )
sleep 0.2
end end
end end
if data[:priority] if data[:priority]
@ -1993,7 +1965,7 @@ wait untill text in selector disabppears
sleep 2.5 sleep 2.5
element.send_keys(:enter) element.send_keys(:enter)
sleep 0.4 sleep 0.2
# ff issue, sometimes enter event gets dropped # ff issue, sometimes enter event gets dropped
# take user manually # take user manually
if instance.find_elements(css: '.content.active .newTicket .js-recipientDropdown.open')[0] if instance.find_elements(css: '.content.active .newTicket .js-recipientDropdown.open')[0]
@ -2038,7 +2010,7 @@ wait untill text in selector disabppears
assert(true, 'ticket created without submit') assert(true, 'ticket created without submit')
return return
end end
sleep 0.5
#instance.execute_script('$(".content.active .newTicket form").submit();') #instance.execute_script('$(".content.active .newTicket form").submit();')
click( click(
browser: instance, browser: instance,
@ -2050,7 +2022,7 @@ wait untill text in selector disabppears
9.times do 9.times do
if instance.current_url.match?(/#{Regexp.quote('#ticket/zoom/')}/) if instance.current_url.match?(/#{Regexp.quote('#ticket/zoom/')}/)
assert(true, 'ticket created') assert(true, 'ticket created')
sleep 2.5 sleep 2
id = instance.current_url id = instance.current_url
id.gsub!(//,) id.gsub!(//,)
id.gsub!(%r{^.+?/(\d+)$}, '\\1') id.gsub!(%r{^.+?/(\d+)$}, '\\1')
@ -2064,7 +2036,6 @@ wait untill text in selector disabppears
title: data[:title], title: data[:title],
} }
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
@ -2316,7 +2287,6 @@ wait untill text in selector disabppears
# do not stay on tab # do not stay on tab
if params[:task_type] == 'closeTab' || params[:task_type] == 'closeNextInOverview' if params[:task_type] == 'closeTab' || params[:task_type] == 'closeNextInOverview'
sleep 1 sleep 1
screenshot(browser: instance, comment: 'ticket_update')
return return
end end
@ -2324,7 +2294,6 @@ 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.blank? if text.blank?
screenshot(browser: instance, comment: 'ticket_update_ok')
sleep 1 sleep 1
return true return true
end end
@ -2428,19 +2397,17 @@ wait untill text in selector disabppears
instance = params[:browser] || @browser instance = params[:browser] || @browser
instance.find_elements(css: '.js-overviewsMenuItem')[0].click instance.find_elements(css: '.js-overviewsMenuItem')[0].click
sleep 1 sleep 0.5
execute( execute(
browser: instance, browser: instance,
js: '$(".content.active .sidebar").css("display", "block")', js: '$(".content.active .sidebar").css("display", "block")',
) )
screenshot(browser: instance, comment: 'ticket_open_by_overview')
instance.find_elements(css: ".content.active .sidebar a[href=\"#{params[:link]}\"]")[0].click instance.find_elements(css: ".content.active .sidebar a[href=\"#{params[:link]}\"]")[0].click
sleep 1 sleep 0.5
execute( execute(
browser: instance, browser: instance,
js: '$(".content.active .sidebar").css("display", "none")', js: '$(".content.active .sidebar").css("display", "none")',
) )
screenshot(browser: instance, comment: 'ticket_open_by_overview_search')
if params[:title] if params[:title]
element = instance.find_element(css: '.content.active').find_element(partial_link_text: params[:title]) element = instance.find_element(css: '.content.active').find_element(partial_link_text: params[:title])
if !element if !element
@ -2461,7 +2428,6 @@ wait untill text in selector disabppears
screenshot(browser: instance, comment: 'ticket_open_by_overview_open_failed_failed') screenshot(browser: instance, comment: 'ticket_open_by_overview_open_failed_failed')
raise "unable to open ticket #{params[:number]}!" raise "unable to open ticket #{params[:number]}!"
end end
sleep 1
assert(true, "ticket #{params[:number]} found") assert(true, "ticket #{params[:number]} found")
true true
end end
@ -2498,7 +2464,6 @@ wait untill text in selector disabppears
sleep 1 sleep 1
# open ticket # open ticket
screenshot(browser: instance, comment: 'ticket_open_by_search')
#instance.find_element(partial_link_text: params[:number] } ).click #instance.find_element(partial_link_text: params[:number] } ).click
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:number]}') .nav-tab-icon\").first().click()") instance.execute_script("$(\".js-global-search-result a:contains('#{params[:number]}') .nav-tab-icon\").first().click()")
sleep 1 sleep 1
@ -2507,7 +2472,6 @@ wait untill text in selector disabppears
screenshot(browser: instance, comment: 'ticket_open_by_search_failed') 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
true true
end end
@ -2534,7 +2498,6 @@ wait untill text in selector disabppears
sleep 3 sleep 3
# open ticket # open ticket
screenshot(browser: instance, comment: 'ticket_open_by_title_search')
#instance.find_element(partial_link_text: params[:title] } ).click #instance.find_element(partial_link_text: params[:title] } ).click
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()") instance.execute_script("$(\".js-global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
sleep 1 sleep 1
@ -2543,7 +2506,6 @@ wait untill text in selector disabppears
screenshot(browser: instance, comment: 'ticket_open_by_title_failed') screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
raise "unable to search/find ticket #{params[:title]}!" raise "unable to search/find ticket #{params[:title]}!"
end end
sleep 1
true true
end end
@ -2632,7 +2594,6 @@ wait untill text in selector disabppears
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")
sleep 2
true true
end end
@ -2657,7 +2618,6 @@ wait untill text in selector disabppears
element.send_keys(params[:value]) element.send_keys(params[:value])
sleep 3 sleep 3
screenshot(browser: instance, comment: 'user_open_by_search')
#instance.find_element(partial_link_text: params[:value]).click #instance.find_element(partial_link_text: params[:value]).click
instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()") instance.execute_script("$(\".js-global-search-result a:contains('#{params[:value]}') .nav-tab-icon\").click()")
sleep 1 sleep 1
@ -2667,7 +2627,6 @@ wait untill text in selector disabppears
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")
sleep 2
true true
end end
@ -3080,7 +3039,6 @@ wait untill text in selector disabppears
modal_ready(browser: instance) modal_ready(browser: instance)
#instance.find_elements(:css => 'label:contains(" ' + action[:name] + '")')[0].click #instance.find_elements(:css => 'label:contains(" ' + action[:name] + '")')[0].click
instance.execute_script('$(".js-groupList tr:contains(\"' + data[:name] + '\") .js-groupListItem[value=' + member[:access] + ']").prop("checked", true)') instance.execute_script('$(".js-groupList tr:contains(\"' + data[:name] + '\") .js-groupListItem[value=' + member[:access] + ']").prop("checked", true)')
screenshot(browser: instance, comment: 'group_create_member')
instance.find_elements(css: '.modal button.js-submit')[0].click instance.find_elements(css: '.modal button.js-submit')[0].click
modal_disappear(browser: instance) modal_disappear(browser: instance)
end end