Skip to content

Commit

Permalink
[FIX] tests: catch runtime exceptions during browser_js tests
Browse files Browse the repository at this point in the history
Actually, when running browser_js tests, the test automatically fails
when a console error is seen.
In some cases, an exception can be thrown during a tour but without
console error. In that case, another type of devtools protocol event is
fired: Runtime.exceptionThorwn. This event is not catched by the
browser_js test.

With this commit the above mentioned event is catched and the test is
directly considered as failed.

closes #31555

Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
  • Loading branch information
d-fence committed Mar 14, 2019
1 parent 9450469 commit 7282a35
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion odoo/tests/common.py
Expand Up @@ -734,7 +734,13 @@ def _wait_code_ok(self, code, timeout):
if res.get('result', {}).get('result').get('subtype', '') == 'error':
self._logger.error("Running code returned an error")
return False
elif res and res.get('method') == 'Runtime.consoleAPICalled' and res.get('params', {}).get('type') in ('log', 'error', 'trace'):
elif res and res.get('method') == 'Runtime.exceptionThrown':
exception_details = res.get('params', {}).get('exceptionDetails', {})
self._logger.error(exception_details)
self.take_screenshot()
self._save_screencast()
return False
elif res and res.get('method') in 'Runtime.consoleAPICalled' and res.get('params', {}).get('type') in ('log', 'error', 'trace'):
logs = res.get('params', {}).get('args')
log_type = res.get('params', {}).get('type')
content = " ".join([str(log.get('value', '')) for log in logs])
Expand Down

0 comments on commit 7282a35

Please sign in to comment.