From 5a523b06cde9a9e21775ee156df91edeb04d745d Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Tue, 28 Aug 2018 10:28:02 +0200 Subject: [PATCH] [FIX] tests: properly stop chrome when no tab found In some situations, Chrome remote debugging is sending an empty list of opened tabs. In that case, an orphan Chrome process stays alive. With this commit, Chrome is stopped properly in those situations. --- odoo/tests/common.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 32e7a45d5fa..b786f4117d0 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -351,6 +351,7 @@ class ChromeBrowser(): self.chrome_process = None self.screencast_frames = [] self._chrome_start() + self._find_websocket() self._logger.info('Websocket url found: %s', self.ws_url) self._open_websocket() self._logger.info('Enable chrome headless console log notification') @@ -419,9 +420,16 @@ class ChromeBrowser(): except OSError: raise unittest.SkipTest("%s not found" % cmd[0]) self._logger.info('Chrome pid: %s', self.chrome_process.pid) + + def _find_websocket(self): version = self._json_command('version') self._logger.info('Browser version: %s', version['Browser']) - infos = self._json_command('')[0] # Infos about the first tab + try: + infos = self._json_command('')[0] # Infos about the first tab + except IndexError: + self._logger.warning('No tab found in Chrome') + self.stop() + raise unittest.SkipTest('No tab found in Chrome') self.ws_url = infos['webSocketDebuggerUrl'] self._logger.info('Chrome headless temporary user profile dir: %s', self.user_data_dir)