From 2424ec15321b5994c6eb43b591230ed2c9f79a66 Mon Sep 17 00:00:00 2001 From: cobalt-github-releaser-bot <95661244+cobalt-github-releaser-bot@users.noreply.github.com> Date: Tue, 2 Jan 2024 16:25:05 -0800 Subject: [PATCH] Cherry pick PR #2140: Android blacboxtests fix, workaround for Python webdriver (#2151) Refer to the original PR: https://github.com/youtube/cobalt/pull/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 Co-authored-by: Kaido Kert --- 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):