Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow downloading of recent versions of chrome #537

Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2b86ad1
allow downloading of modern_versions of chrome
david-engelmann Jul 19, 2023
1abbd90
use _http_client
david-engelmann Jul 19, 2023
185e872
fix filepath creation in File object
david-engelmann Jul 19, 2023
27527b8
set version check to last tag on old url
david-engelmann Jul 19, 2023
0038a9c
inspect latest_release_url
david-engelmann Jul 19, 2023
6334866
trying latest with version over 114 is failing
david-engelmann Jul 19, 2023
802af19
try to set a working latest_release_url
david-engelmann Jul 19, 2023
dfe4626
fix version check criteria
david-engelmann Jul 19, 2023
9617cf3
fix log typo
david-engelmann Jul 19, 2023
5201ef7
didnt find version for cicd pipeline, checkout os_type
david-engelmann Jul 19, 2023
2fdf352
see determined browser version as well
david-engelmann Jul 19, 2023
70019c1
browser_version not coming back with final 2 digits
david-engelmann Jul 19, 2023
d5ef079
inspect chrome type passed
david-engelmann Jul 19, 2023
460022b
checkout stdout from read_version_from_cmd
david-engelmann Jul 19, 2023
a183a7a
update version regex pattern
david-engelmann Jul 19, 2023
f696681
google not chromium
david-engelmann Jul 19, 2023
b160b98
cleanup comments execpt final url
david-engelmann Jul 19, 2023
51c3aa7
driver_version_to_download inspection
david-engelmann Jul 19, 2023
e5c93cd
pipelines running out of space?
david-engelmann Jul 19, 2023
12b8f50
return determined_browser version if over 114
david-engelmann Jul 19, 2023
fce4afe
remove license from archive.namelist()
david-engelmann Jul 19, 2023
03efd0a
fix the changes in filepath from new zips
david-engelmann Jul 19, 2023
75154f0
set version floor to 114.0.5735.00
david-engelmann Jul 20, 2023
a5bb766
mac-arm64 instead of mac_arm64
david-engelmann Jul 20, 2023
28de1b6
change mac_x64 to mac-x64
david-engelmann Jul 20, 2023
efdc9c6
fix permission error on mac
david-engelmann Jul 21, 2023
887b53c
update version check to 115
david-engelmann Jul 21, 2023
f360dc1
Merge branch 'de-upgrade-chrome-version' of github.com:david-engelman…
david-engelmann Jul 21, 2023
9fde87a
support build version and simple version
david-engelmann Jul 21, 2023
84272a8
fail better with unknown version
david-engelmann Jul 21, 2023
841cc09
Merge branch 'master' into de-upgrade-chrome-version
david-engelmann Jul 22, 2023
e9c7f67
remove unused param
david-engelmann Jul 22, 2023
5e742c1
use determined browser version above 113
david-engelmann Jul 22, 2023
2617c16
issue with using determined_browser_version with 113
david-engelmann Jul 22, 2023
6355e71
get_url_for_version_and_platform to return url always
david-engelmann Jul 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions webdriver_manager/core/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,18 @@ def __extract_zip(self, to_directory):
"Permission denied",
]:
raise e
file_names = []
for n in archive.namelist():
if "/" not in n:
file_names.append(n)
else:
file_path, file_name = n.split("/")
full_file_path = os.path.join(to_directory, file_path)
source = os.path.join(full_file_path, file_name)
destination = os.path.join(to_directory, file_name)
os.rename(source, destination)
file_names.append(file_name)
return sorted(file_names, key=lambda x: x.lower())
return archive.namelist()
file_names = []
for n in archive.namelist():
if "/" not in n:
file_names.append(n)
else:
file_path, file_name = n.split("/")
full_file_path = os.path.join(to_directory, file_path)
source = os.path.join(full_file_path, file_name)
destination = os.path.join(to_directory, file_name)
os.rename(source, destination)
file_names.append(file_name)
return sorted(file_names, key=lambda x: x.lower())

def __extract_tar_file(self, to_directory):
try:
Expand Down
13 changes: 9 additions & 4 deletions webdriver_manager/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@ def filename(self) -> str:
return self.file_name
try:
content = self.__stream.headers["content-disposition"]

content_disposition_list = re.split(";", content)
filenames = [re.findall(self.__regex_filename, element) for element in content_disposition_list]
filename = next(filter(None, next(filter(None, next(filter(None, filenames))))))
if "attachment" in content.lower():
if "octe" in self.__stream.headers["content-type"]:
filename = f"{self.__temp_name}.zip"
else:
raise Exception("Unknown Attachment Type")
else:
content_disposition_list = re.split(";", content)
filenames = [re.findall(self.__regex_filename, element) for element in content_disposition_list]
filename = next(filter(None, next(filter(None, next(filter(None, filenames)))))) # type: ignore
except KeyError:
filename = f"{self.__temp_name}.zip"
except (IndexError, StopIteration):
Expand Down
47 changes: 42 additions & 5 deletions webdriver_manager/drivers/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from webdriver_manager.core.driver import Driver
from webdriver_manager.core.logger import log
from webdriver_manager.core.utils import ChromeType, is_arch, is_mac_os
import re


class ChromeDriver(Driver):
Expand Down Expand Up @@ -45,15 +46,30 @@ def get_driver_download_url(self):
if version.parse(driver_version_to_download) < version.parse("106.0.5249.61"):
os_type = os_type.replace("mac_arm64", "mac64_m1")

if version.parse(driver_version_to_download) >= version.parse("113"):
if version.parse(driver_version_to_download) >= version.parse("115"):
if os_type == "mac64":
os_type = "mac-x64"
if os_type == "mac_x64":
os_type = "mac-x64"
if os_type in ["mac_64", "mac64_m1", "mac_arm64"]:
os_type = "mac-arm64"

modern_version_url = self.get_url_for_version_and_platform(driver_version_to_download, os_type)
log(f"Modern chrome version {modern_version_url}")
return modern_version_url
if modern_version_url != None:
log(f"Modern chrome version {modern_version_url}")
return modern_version_url
else:
if len(driver_version_to_download) < 4:
release_version = self.get_latest_release_for_version(driver_version_to_download)
modern_version_url = self.get_url_for_version_and_platform(release_version, os_type)
if modern_version_url != None:
log(f"Modern chrome version {modern_version_url}")
return modern_version_url
elif re.search(r"^\d+\.\d+\.\d+$", driver_version_to_download):
release_version = self.get_latest_patch_version_for_build_version(build_version=driver_version_to_download)
modern_version_url = self.get_url_for_version_and_platform(release_version, os_type)
if modern_version_url != None:
log(f"Modern chrome version {modern_version_url}")
return modern_version_url

return f"{self._url}/{driver_version_to_download}/{self.get_name()}_{os_type}.zip"

Expand All @@ -62,6 +78,11 @@ def get_browser_type(self):

def get_latest_release_version(self):
determined_browser_version = self.get_browser_version_from_os()

if isinstance(determined_browser_version, str):
if version.parse(determined_browser_version) >= version.parse("115"):
return determined_browser_version

log(f"Get LATEST {self._name} version for {self._browser_type}")
if version.parse(determined_browser_version) >= version.parse("113"):
return determined_browser_version
Expand All @@ -74,6 +95,7 @@ def get_latest_release_version(self):
resp = self._http_client.get(url=latest_release_url)
return resp.text.rstrip()


def get_url_for_version_and_platform(self, browser_version, platform):
url = "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
response = self._http_client.get(url)
Expand All @@ -85,5 +107,20 @@ def get_url_for_version_and_platform(self, browser_version, platform):
for d in downloads:
if d["platform"] == platform:
return d["url"]
return None

raise Exception(f"No such driver version {browser_version} for {platform}")
def get_latest_release_for_version(self, version):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyPirogov Here is the function for latest release by short version ie. 115

url = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json"
response = self._http_client.get(url)
data = response.json()
versions =[v["version"] for v in data["channels"].values()]
for v in versions:
if version in v:
return v
return None

def get_latest_patch_version_for_build_version(self, build_version):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyPirogov Here is the function for latest release by build version ie. 115.0.5735

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, why do we need it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyPirogov The old LATEST_RELEASE url supported those style lookups. ie. https://chromedriver.storage.googleapis.com/LATEST_RELEASE_113 and https://chromedriver.storage.googleapis.com/LATEST_RELEASE_114.0.5735. It was suggested we retain that for versions over 115. Without that, users will have to pass in the full browser version ie. version="114.0.5735.90", which can change frequently. Either way, I'm fine including for backwards compatibility, I'm fine with removing for simplicity and add an exception that explains as suggested by you

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd postpone this, because what I see know is that browser version is equal to the one mentioned in their driver website. Moreover I think that fix should be applied in method get_url_for_version_and_platform

url = "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build.json"
response = self._http_client.get(url)
data = response.json()
return data["builds"][build_version]["version"]