Update __init__.py

This commit is contained in:
Leon 2019-12-22 14:27:20 +01:00 committed by GitHub
parent cebddec58e
commit 9f727e1f46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 4 deletions

View File

@ -138,18 +138,17 @@ class ChromeDriverManager(object):
installed = False installed = False
selenium_patched = False selenium_patched = False
def __init__(self, executable_path=None, target_version=None, *args, **kwargs): def __init__(self, executable_path=None, target_version=None, *args, **kwargs):
self.executable_path = executable_path or "chromedriver.exe" self.executable_path = executable_path or "chromedriver.exe"
self.platform = sys.platform self.platform = sys.platform
self.target_version = target_version self.target_version = target_version
def patch_selenium_webdriver(self_): def patch_selenium_webdriver(self_):
""" """
Patches existing webdriver path on <executable_path> OR if executable_path is None, will download Patches selenium package Chrome, ChromeOptions classes for current session
and patch a new webdriver binary for chrome <version_int> (automatically finds latest release of main version)
:param str executable_path: OPTIONAL path to existing chromedriver executable to patch
:param int version_int: OPTIONAL target chrome main version. default 79
:return: :return:
""" """
import selenium.webdriver.chrome.service import selenium.webdriver.chrome.service
@ -161,6 +160,7 @@ class ChromeDriverManager(object):
) )
self_.__class__.selenium_patched = True self_.__class__.selenium_patched = True
def install(self, patch_selenium=True): def install(self, patch_selenium=True):
""" """
Initialize the patch Initialize the patch
@ -185,6 +185,7 @@ class ChromeDriverManager(object):
if patch_selenium: if patch_selenium:
self.patch_selenium_webdriver() self.patch_selenium_webdriver()
def get_release_version_number(self): def get_release_version_number(self):
""" """
Gets the latest major version available, or the latest major version of self.target_version if set explicitly. Gets the latest major version available, or the latest major version of self.target_version if set explicitly.
@ -198,6 +199,7 @@ class ChromeDriverManager(object):
) )
return urlopen(_DL_BASE + path).read().decode() return urlopen(_DL_BASE + path).read().decode()
def fetch_chromedriver(self): def fetch_chromedriver(self):
""" """
Downloads ChromeDriver from source and unpacks the executable Downloads ChromeDriver from source and unpacks the executable
@ -217,6 +219,7 @@ class ChromeDriverManager(object):
os.remove(zip_name) os.remove(zip_name)
return exe_name return exe_name
def patch_binary(self): def patch_binary(self):
""" """
Patches the ChromeDriver binary Patches the ChromeDriver binary