Skip to content

Commit

Permalink
Android blacboxtests fix, workaround for Python webdriver (#2140)
Browse files Browse the repository at this point in the history
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 0f56fd5)
  • Loading branch information
kaidokert authored and anonymous1-me committed Jan 2, 2024
1 parent dc4f26e commit c4be3d5
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 c4be3d5

Please sign in to comment.