Is there a way to capture errors occurring in the DOM in Selenium and probably flag the same as an error in the page?
To give a brief exam
Here my solution inspiring by jhanifen's response:
// common.js - js file common to the entire app
globalError = []
window.onerror = function (msg, url, line, col, error) {
globalError.push({msg:msg, url:url, line:line})
};
# tests.py
def tearDown(driver):
# assert on js error
ret = driver.selenium.execute_script("return globalError ")
driver.assertFalse(ret, "errors %r " % ret)
# ret will be a dict looking like
# {'line': 50, 'url': 'http://localhost:8081/static/js/common.js', 'msg': 'Uncaught ReferenceError: s is not defined'}