From 673889230de666e32b58d43bc1961ff77c41c579 Mon Sep 17 00:00:00 2001 From: Kaido Kert Date: Fri, 29 Dec 2023 11:52:22 -0800 Subject: [PATCH] Android blacboxtests fix, workaround for Python webdriver (#2140) This makes sure that Webdriver Remote connection is initialized with a timeout value before the timeout value gets used. Avoids errors coming from incompatible urrlib/request/webdriver packages using different global timeout values. b/318024704 (cherry picked from commit 0f56fd5d4f1858e0b679daa13326cd968f13fe9e) --- cobalt/tools/automated_testing/cobalt_runner.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cobalt/tools/automated_testing/cobalt_runner.py b/cobalt/tools/automated_testing/cobalt_runner.py index 43928dd7259c..897be083e314 100644 --- a/cobalt/tools/automated_testing/cobalt_runner.py +++ b/cobalt/tools/automated_testing/cobalt_runner.py @@ -333,9 +333,13 @@ def _KillLauncher(self): def _StartWebdriver(self, port): host, webdriver_port = self.launcher.GetHostAndPortGivenPort(port) self.webdriver_url = f'http://{host}:{webdriver_port}/' + + # Create remote and set a timeout before making the connection + rc = self.selenium_webdriver_module.remote.remote_connection + executor = rc.RemoteConnection(self.webdriver_url) + executor.set_timeout(WEBDRIVER_HTTP_TIMEOUT_SECONDS) self.webdriver = self.selenium_webdriver_module.Remote( - self.webdriver_url, COBALT_WEBDRIVER_CAPABILITIES) - self.webdriver.command_executor.set_timeout(WEBDRIVER_HTTP_TIMEOUT_SECONDS) + executor, COBALT_WEBDRIVER_CAPABILITIES) logging.info('Selenium Connected') self.test_script_started.set() @@ -344,11 +348,12 @@ def ReconnectWebDriver(self): if self.webdriver: self.webdriver.quit() if self.webdriver_url: + rc = self.selenium_webdriver_module.remote.remote_connection + executor = rc.RemoteConnection(self.webdriver_url) + executor.set_timeout(WEBDRIVER_HTTP_TIMEOUT_SECONDS) self.webdriver = self.selenium_webdriver_module.Remote( - self.webdriver_url, COBALT_WEBDRIVER_CAPABILITIES) + executor, COBALT_WEBDRIVER_CAPABILITIES) if self.webdriver: - self.webdriver.command_executor.set_timeout( - WEBDRIVER_HTTP_TIMEOUT_SECONDS) logging.info('Selenium Reconnected') def WaitForStart(self):