Skip to content

Commit

Permalink
Cherry pick PR #2140: Android blacboxtests fix, workaround for Python…
Browse files Browse the repository at this point in the history
… webdriver (#2151)

Refer to the original PR: #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 <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and kaidokert committed Jan 3, 2024
1 parent 2d4cddd commit 2424ec1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cobalt/tools/automated_testing/cobalt_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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):
Expand Down

0 comments on commit 2424ec1

Please sign in to comment.