Improved error handling.
This commit is contained in:
parent
bb80811745
commit
4f07fb09e6
1 changed files with 46 additions and 4 deletions
|
@ -195,6 +195,11 @@ class TestCase < Test::Unit::TestCase
|
||||||
|
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
instance.get( params[:url] )
|
instance.get( params[:url] )
|
||||||
|
|
||||||
|
# check if reload was successfull
|
||||||
|
if !instance.find_elements( { css: 'body' } )[0] || instance.find_elements( { css: 'body' } )[0].text =~ /unavailable or too busy/i
|
||||||
|
instance.navigate.refresh
|
||||||
|
end
|
||||||
screenshot( browser: instance, comment: 'location' )
|
screenshot( browser: instance, comment: 'location' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -234,6 +239,11 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance = params[:browser] || @browser
|
instance = params[:browser] || @browser
|
||||||
screenshot( browser: instance, comment: 'reload_before' )
|
screenshot( browser: instance, comment: 'reload_before' )
|
||||||
instance.navigate.refresh
|
instance.navigate.refresh
|
||||||
|
|
||||||
|
# check if reload was successfull
|
||||||
|
if !instance.find_elements( { css: 'body' } )[0] || instance.find_elements( { css: 'body' } )[0].text =~ /unavailable or too busy/i
|
||||||
|
instance.navigate.refresh
|
||||||
|
end
|
||||||
screenshot( browser: instance, comment: 'reload_after' )
|
screenshot( browser: instance, comment: 'reload_after' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -243,12 +253,14 @@ class TestCase < Test::Unit::TestCase
|
||||||
browser: browser1,
|
browser: browser1,
|
||||||
css: '.some_class',
|
css: '.some_class',
|
||||||
fast: false, # do not wait
|
fast: false, # do not wait
|
||||||
|
wait: 1, # wait 1 sec.
|
||||||
)
|
)
|
||||||
|
|
||||||
click(
|
click(
|
||||||
browser: browser1,
|
browser: browser1,
|
||||||
text: '.partial_link_text',
|
text: '.partial_link_text',
|
||||||
fast: false, # do not wait
|
fast: false, # do not wait
|
||||||
|
wait: 1, # wait 1 sec.
|
||||||
)
|
)
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
@ -274,6 +286,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
instance.find_elements( { partial_link_text: params[:text] } )[0].click
|
instance.find_elements( { partial_link_text: params[:text] } )[0].click
|
||||||
end
|
end
|
||||||
sleep 0.4 if !params[:fast]
|
sleep 0.4 if !params[:fast]
|
||||||
|
sleep params[:wait] if params[:wait]
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -440,6 +453,35 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
switch(
|
||||||
|
browser: browser1,
|
||||||
|
css: '.some_class',
|
||||||
|
type: 'on', # 'off'
|
||||||
|
)
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def switch(params)
|
||||||
|
switch_window_focus(params)
|
||||||
|
log('switch', params)
|
||||||
|
|
||||||
|
instance = params[:browser] || @browser
|
||||||
|
|
||||||
|
element = instance.find_elements( { css: "#{params[:css]} input[type=checkbox]" } )[0]
|
||||||
|
checked = element.attribute('checked')
|
||||||
|
if !checked
|
||||||
|
if params[:type] == 'on'
|
||||||
|
instance.find_elements( { css: "#{params[:css]} label" } )[0].click
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if params[:type] == 'off'
|
||||||
|
instance.find_elements( { css: "#{params[:css]} label" } )[0].click
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
check(
|
check(
|
||||||
|
|
Loading…
Reference in a new issue