Update driver options
This commit is contained in:
parent
4def25a160
commit
ae4b33d51a
|
@ -225,7 +225,7 @@ def chromedriver_on_path():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_uc_driver_version():
|
def get_uc_driver_version(full=False):
|
||||||
uc_driver_version = None
|
uc_driver_version = None
|
||||||
if os.path.exists(LOCAL_UC_DRIVER):
|
if os.path.exists(LOCAL_UC_DRIVER):
|
||||||
try:
|
try:
|
||||||
|
@ -236,8 +236,12 @@ def get_uc_driver_version():
|
||||||
output = output.decode("latin1")
|
output = output.decode("latin1")
|
||||||
else:
|
else:
|
||||||
output = output.decode("utf-8")
|
output = output.decode("utf-8")
|
||||||
|
full_version = output.split(" ")[1]
|
||||||
output = output.split(" ")[1].split(".")[0]
|
output = output.split(" ")[1].split(".")[0]
|
||||||
if int(output) >= 72:
|
if int(output) >= 72:
|
||||||
|
if full:
|
||||||
|
uc_driver_version = full_version
|
||||||
|
else:
|
||||||
uc_driver_version = output
|
uc_driver_version = output
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
@ -2158,6 +2162,9 @@ def get_local_driver(
|
||||||
}
|
}
|
||||||
use_version = "latest"
|
use_version = "latest"
|
||||||
major_edge_version = None
|
major_edge_version = None
|
||||||
|
saved_mev = None
|
||||||
|
use_br_version_for_edge = False
|
||||||
|
use_exact_version_for_edge = False
|
||||||
try:
|
try:
|
||||||
if binary_location:
|
if binary_location:
|
||||||
try:
|
try:
|
||||||
|
@ -2165,7 +2172,9 @@ def get_local_driver(
|
||||||
detect_b_ver.get_browser_version_from_binary(
|
detect_b_ver.get_browser_version_from_binary(
|
||||||
binary_location
|
binary_location
|
||||||
)
|
)
|
||||||
).split(".")[0]
|
)
|
||||||
|
saved_mev = major_edge_version
|
||||||
|
major_edge_version = saved_mev.split(".")[0]
|
||||||
if len(major_edge_version) < 2:
|
if len(major_edge_version) < 2:
|
||||||
major_edge_version = None
|
major_edge_version = None
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -2174,11 +2183,25 @@ def get_local_driver(
|
||||||
br_app = "edge"
|
br_app = "edge"
|
||||||
major_edge_version = (
|
major_edge_version = (
|
||||||
detect_b_ver.get_browser_version_from_os(br_app)
|
detect_b_ver.get_browser_version_from_os(br_app)
|
||||||
).split(".")[0]
|
)
|
||||||
|
saved_mev = major_edge_version
|
||||||
|
major_edge_version = major_edge_version.split(".")[0]
|
||||||
if int(major_edge_version) < 80:
|
if int(major_edge_version) < 80:
|
||||||
major_edge_version = None
|
major_edge_version = None
|
||||||
|
elif int(major_edge_version) >= 115:
|
||||||
|
if (
|
||||||
|
driver_version == "browser"
|
||||||
|
and saved_mev
|
||||||
|
and len(saved_mev.split(".")) == 4
|
||||||
|
):
|
||||||
|
driver_version = saved_mev
|
||||||
|
use_br_version_for_edge = True
|
||||||
except Exception:
|
except Exception:
|
||||||
major_edge_version = None
|
major_edge_version = None
|
||||||
|
if driver_version and "." in driver_version:
|
||||||
|
use_exact_version_for_edge = True
|
||||||
|
if use_br_version_for_edge:
|
||||||
|
major_edge_version = saved_mev
|
||||||
if major_edge_version:
|
if major_edge_version:
|
||||||
use_version = major_edge_version
|
use_version = major_edge_version
|
||||||
edge_driver_version = None
|
edge_driver_version = None
|
||||||
|
@ -2194,18 +2217,19 @@ def get_local_driver(
|
||||||
output = output.decode("utf-8")
|
output = output.decode("utf-8")
|
||||||
if output.split(" ")[0] == "MSEdgeDriver":
|
if output.split(" ")[0] == "MSEdgeDriver":
|
||||||
# MSEdgeDriver VERSION
|
# MSEdgeDriver VERSION
|
||||||
output = output.split(" ")[1].split(".")[0]
|
output = output.split(" ")[1]
|
||||||
|
if use_exact_version_for_edge:
|
||||||
|
edge_driver_version = output.split(" ")[0]
|
||||||
|
output = output.split(".")[0]
|
||||||
elif output.split(" ")[0] == "Microsoft":
|
elif output.split(" ")[0] == "Microsoft":
|
||||||
# Microsoft Edge WebDriver VERSION
|
output = output.split(" ")[3]
|
||||||
if (
|
if use_exact_version_for_edge:
|
||||||
"WebDriver 115.0" in output
|
edge_driver_version = output.split(" ")[0]
|
||||||
and "115.0.1901.183" not in output
|
output = output.split(".")[0]
|
||||||
):
|
|
||||||
edgedriver_upgrade_needed = True
|
|
||||||
output = output.split(" ")[3].split(".")[0]
|
|
||||||
else:
|
else:
|
||||||
output = 0
|
output = 0
|
||||||
if int(output) >= 2:
|
if int(output) >= 2:
|
||||||
|
if not use_exact_version_for_edge:
|
||||||
edge_driver_version = output
|
edge_driver_version = output
|
||||||
if driver_version == "keep":
|
if driver_version == "keep":
|
||||||
driver_version = edge_driver_version
|
driver_version = edge_driver_version
|
||||||
|
@ -2639,8 +2663,10 @@ def get_local_driver(
|
||||||
)
|
)
|
||||||
use_version = "latest"
|
use_version = "latest"
|
||||||
major_chrome_version = None
|
major_chrome_version = None
|
||||||
|
saved_mcv = None
|
||||||
full_ch_version = None
|
full_ch_version = None
|
||||||
full_ch_driver_version = None
|
full_ch_driver_version = None
|
||||||
|
use_br_version_for_uc = False
|
||||||
try:
|
try:
|
||||||
if chrome_options.binary_location:
|
if chrome_options.binary_location:
|
||||||
try:
|
try:
|
||||||
|
@ -2648,7 +2674,9 @@ def get_local_driver(
|
||||||
detect_b_ver.get_browser_version_from_binary(
|
detect_b_ver.get_browser_version_from_binary(
|
||||||
chrome_options.binary_location,
|
chrome_options.binary_location,
|
||||||
)
|
)
|
||||||
).split(".")[0]
|
)
|
||||||
|
saved_mcv = major_chrome_version
|
||||||
|
major_chrome_version = saved_mcv.split(".")[0]
|
||||||
if len(major_chrome_version) < 2:
|
if len(major_chrome_version) < 2:
|
||||||
major_chrome_version = None
|
major_chrome_version = None
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -2658,6 +2686,7 @@ def get_local_driver(
|
||||||
full_ch_version = (
|
full_ch_version = (
|
||||||
detect_b_ver.get_browser_version_from_os(br_app)
|
detect_b_ver.get_browser_version_from_os(br_app)
|
||||||
)
|
)
|
||||||
|
saved_mcv = full_ch_version
|
||||||
major_chrome_version = full_ch_version.split(".")[0]
|
major_chrome_version = full_ch_version.split(".")[0]
|
||||||
if int(major_chrome_version) < 67:
|
if int(major_chrome_version) < 67:
|
||||||
major_chrome_version = None
|
major_chrome_version = None
|
||||||
|
@ -2667,6 +2696,15 @@ def get_local_driver(
|
||||||
):
|
):
|
||||||
# chromedrivers 2.41 - 2.46 could be swapped with 72
|
# chromedrivers 2.41 - 2.46 could be swapped with 72
|
||||||
major_chrome_version = "72"
|
major_chrome_version = "72"
|
||||||
|
elif int(major_chrome_version) >= 115:
|
||||||
|
if (
|
||||||
|
driver_version == "browser"
|
||||||
|
and saved_mcv
|
||||||
|
and len(saved_mcv.split(".")) == 4
|
||||||
|
):
|
||||||
|
driver_version = saved_mcv
|
||||||
|
if is_using_uc(undetectable, browser_name):
|
||||||
|
use_br_version_for_uc = True
|
||||||
except Exception:
|
except Exception:
|
||||||
major_chrome_version = None
|
major_chrome_version = None
|
||||||
if major_chrome_version:
|
if major_chrome_version:
|
||||||
|
@ -2717,6 +2755,10 @@ def get_local_driver(
|
||||||
disable_build_check = True
|
disable_build_check = True
|
||||||
uc_driver_version = None
|
uc_driver_version = None
|
||||||
if is_using_uc(undetectable, browser_name):
|
if is_using_uc(undetectable, browser_name):
|
||||||
|
if use_br_version_for_uc:
|
||||||
|
uc_driver_version = get_uc_driver_version(full=True)
|
||||||
|
full_ch_driver_version = uc_driver_version
|
||||||
|
else:
|
||||||
uc_driver_version = get_uc_driver_version()
|
uc_driver_version = get_uc_driver_version()
|
||||||
if multi_proxy:
|
if multi_proxy:
|
||||||
sb_config.multi_proxy = True
|
sb_config.multi_proxy = True
|
||||||
|
@ -2774,7 +2816,10 @@ def get_local_driver(
|
||||||
):
|
):
|
||||||
full_ch_v_p = full_ch_version.split(".")[0:2]
|
full_ch_v_p = full_ch_version.split(".")[0:2]
|
||||||
full_ch_driver_v_p = full_ch_driver_version.split(".")[0:2]
|
full_ch_driver_v_p = full_ch_driver_version.split(".")[0:2]
|
||||||
if full_ch_v_p == full_ch_driver_v_p:
|
if (
|
||||||
|
full_ch_v_p == full_ch_driver_v_p
|
||||||
|
or driver_version == "keep"
|
||||||
|
):
|
||||||
browser_driver_close_match = True
|
browser_driver_close_match = True
|
||||||
# If not ARM MAC and need to use uc_driver (and it's missing),
|
# If not ARM MAC and need to use uc_driver (and it's missing),
|
||||||
# and already have chromedriver with the correct version,
|
# and already have chromedriver with the correct version,
|
||||||
|
@ -2821,6 +2866,12 @@ def get_local_driver(
|
||||||
and use_version != "latest" # Browser version detected
|
and use_version != "latest" # Browser version detected
|
||||||
and uc_driver_version != use_version
|
and uc_driver_version != use_version
|
||||||
)
|
)
|
||||||
|
or (
|
||||||
|
full_ch_driver_version # Also used for the uc_driver
|
||||||
|
and driver_version
|
||||||
|
and len(str(driver_version).split(".")) == 4
|
||||||
|
and full_ch_driver_version != driver_version
|
||||||
|
)
|
||||||
):
|
):
|
||||||
# chromedriver download needed in the seleniumbase/drivers dir
|
# chromedriver download needed in the seleniumbase/drivers dir
|
||||||
from seleniumbase.console_scripts import sb_install
|
from seleniumbase.console_scripts import sb_install
|
||||||
|
|
|
@ -235,6 +235,10 @@ def get_browser_version_from_binary(binary_location):
|
||||||
binary_location = binary_location.replace(" ", r"\ ")
|
binary_location = binary_location.replace(" ", r"\ ")
|
||||||
cmd_mapping = binary_location + " --version"
|
cmd_mapping = binary_location + " --version"
|
||||||
pattern = r"\d+\.\d+\.\d+"
|
pattern = r"\d+\.\d+\.\d+"
|
||||||
|
quad_pattern = r"\d+\.\d+\.\d+\.\d+"
|
||||||
|
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
|
||||||
|
if quad_version and len(str(quad_version)) >= 9: # Eg. 115.0.0.0
|
||||||
|
return quad_version
|
||||||
version = read_version_from_cmd(cmd_mapping, pattern)
|
version = read_version_from_cmd(cmd_mapping, pattern)
|
||||||
return version
|
return version
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -332,6 +336,10 @@ def get_browser_version_from_os(browser_type):
|
||||||
try:
|
try:
|
||||||
cmd_mapping = cmd_mapping[browser_type][os_name()]
|
cmd_mapping = cmd_mapping[browser_type][os_name()]
|
||||||
pattern = PATTERN[browser_type]
|
pattern = PATTERN[browser_type]
|
||||||
|
quad_pattern = r"\d+\.\d+\.\d+\.\d+"
|
||||||
|
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
|
||||||
|
if quad_version and len(str(quad_version)) >= 9: # Eg. 115.0.0.0
|
||||||
|
return quad_version
|
||||||
version = read_version_from_cmd(cmd_mapping, pattern)
|
version = read_version_from_cmd(cmd_mapping, pattern)
|
||||||
return version
|
return version
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue