Capture js errors of clients.
This commit is contained in:
parent
11e1cd471e
commit
6767970bab
1 changed files with 25 additions and 1 deletions
|
@ -52,11 +52,35 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local_browser.manage.timeouts.implicit_wait = 3 # seconds
|
local_browser.manage.timeouts.implicit_wait = 3 # seconds
|
||||||
|
|
||||||
|
browser_instance_js_on_start(local_browser)
|
||||||
|
end
|
||||||
|
|
||||||
|
def browser_instance_js_on_start(instance)
|
||||||
|
instance.execute_script('
|
||||||
|
window.jsErrors = [];
|
||||||
|
window.onerror = function(errorMessage) {
|
||||||
|
window.jsErrors.push(errorMessage);
|
||||||
|
};');
|
||||||
|
end
|
||||||
|
|
||||||
|
def browser_instance_js_on_teardown(instance)
|
||||||
|
result = instance.execute_script( 'return window.jsErrors;' )
|
||||||
|
if result
|
||||||
|
puts 'JS ERRORS: ' + result.inspect
|
||||||
|
else
|
||||||
|
puts 'JS ERRORS: -none-'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
return if !@browsers
|
return if !@browsers
|
||||||
|
|
||||||
|
# show js errors
|
||||||
|
@browsers.each{ |local_browser|
|
||||||
|
browser_instance_js_on_teardown(local_browser)
|
||||||
|
}
|
||||||
|
|
||||||
# only shut down browser type once on local webdriver tests
|
# only shut down browser type once on local webdriver tests
|
||||||
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
|
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
|
||||||
if !ENV['REMOTE_URL']
|
if !ENV['REMOTE_URL']
|
||||||
|
@ -160,7 +184,7 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def browser_element_action(test, action, instance)
|
def browser_element_action(test, action, instance)
|
||||||
puts "NOTICE #{Time.now.to_s}: " + action.inspect
|
puts "NOTICE #{Time.now.to_s}: " + action.inspect
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
if action[:css]
|
if action[:css]
|
||||||
if action[:css].match '###stack###'
|
if action[:css].match '###stack###'
|
||||||
|
|
Loading…
Reference in a new issue