Skip to content

Commit

Permalink
[aibo_selenium_ros] get chromium version and set it for chrome driver…
Browse files Browse the repository at this point in the history
… automatically
  • Loading branch information
sktometometo committed Sep 15, 2023
1 parent 257fb11 commit 7cbcd36
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import random
import time
import subprocess

import selenium
import undetected_chromedriver as uc
Expand All @@ -23,7 +24,8 @@ def __init__(self,
login_pw='',
auto_login=True,
headless=False,
timeout=20.):
timeout=20.,
chromium_main_version=None):

self.initialized = False

Expand All @@ -33,7 +35,12 @@ def __init__(self,
if chrome_executable_path is not None:
options.binary_location = chrome_executable_path

self.driver = uc.Chrome(executable_path=webdriver_path, options=options)
if chromium_main_version is None:
result = subprocess.check_output("{} --version".format(chrome_executable_path), shell=True)
chromium_main_version = int(result.decode("utf-8").split(" ")[1].split(".")[0])

print(f"chrome main versoin: {chromium_main_version}")
self.driver = uc.Chrome(executable_path=webdriver_path, options=options, version_main=chromium_main_version)
logger.info(f"navigator.webdriver: {self.driver.execute_script('return navigator.webdriver')}")

if not auto_login:
Expand Down

0 comments on commit 7cbcd36

Please sign in to comment.