From 7282a354c23d0e4794c78aca459f4abddc4b0ccb Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Wed, 27 Feb 2019 13:56:30 +0000 Subject: [PATCH] [FIX] tests: catch runtime exceptions during browser_js tests 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 odoo/odoo#31555 Signed-off-by: Christophe Monniez (moc) --- odoo/tests/common.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index f5b04f7e30705..472f0a28ea86f 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -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])