Capture js errors of clients.

This commit is contained in:
Martin Edenhofer 2013-08-20 22:37:39 +02:00
parent 11e1cd471e
commit 6767970bab

View file

@ -52,11 +52,35 @@ class TestCase < Test::Unit::TestCase
end
end
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
def teardown
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
# otherwise this error will happen "Errno::ECONNREFUSED: Connection refused - connect(2)"
if !ENV['REMOTE_URL']