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's the python webdriver solution I use:
def check_browser_errors(driver):
"""
Checks browser for errors, returns a list of errors
:param driver:
:return:
"""
try:
browserlogs = driver.get_log('browser')
except (ValueError, WebDriverException) as e:
# Some browsers does not support getting logs
LOGGER.debug("Could not get browser logs for driver %s due to exception: %s",
driver, e)
return []
errors = []
for entry in browserlogs:
if entry['level'] == 'SEVERE':
errors.append(entry)
return errors