Skip to content

Commit

Permalink
Support latest chrome driver version (#445)
Browse files Browse the repository at this point in the history
* Make tests compatible to arm mac CPUs
  • Loading branch information
alexander-gridnev authored Oct 2, 2022
1 parent 6b17f06 commit dc73f4a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[requires]
python = "3.7"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_brave_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable):
"ssl_disabled",
)
driver_path = ChromeDriverManager(
version="83.0.4103.39",
version="87.0.4280.88",
path=custom_path,
chrome_type=ChromeType.BRAVE,
).install()
Expand All @@ -25,7 +25,7 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable):


def test_brave_manager_with_specific_version():
bin_path = ChromeDriverManager("2.27", chrome_type=ChromeType.BRAVE).install()
bin_path = ChromeDriverManager("87.0.4280.88", chrome_type=ChromeType.BRAVE).install()
assert os.path.exists(bin_path)


Expand All @@ -48,7 +48,7 @@ def test_brave_manager_with_selenium():
def test_driver_can_be_saved_to_custom_path():
custom_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "custom")

path = ChromeDriverManager(version="2.27", path=custom_path,
path = ChromeDriverManager(version="87.0.4280.88", path=custom_path,
chrome_type=ChromeType.BRAVE).install()
assert os.path.exists(path)
assert custom_path in path
Expand Down
11 changes: 8 additions & 3 deletions tests/test_chrome_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,25 @@ def test_chrome_manager_with_cache(delete_drivers_dir):


def test_chrome_manager_with_specific_version(delete_drivers_dir):
bin = ChromeDriverManager("2.26").install()
bin = ChromeDriverManager("87.0.4280.88").install()
assert os.path.exists(bin)


def test_106_0_5249_61_chrome_version(delete_drivers_dir):
bin = ChromeDriverManager("106.0.5249.61").install()
assert os.path.exists(bin)


def test_chrome_manager_with_project_root_local_folder(delete_drivers_dir):
os.environ['WDM_LOCAL'] = "1"
bin = ChromeDriverManager("2.26").install()
bin = ChromeDriverManager("87.0.4280.88").install()
os.environ['WDM_LOCAL'] = "0"
assert os.path.exists(bin)


def test_driver_can_be_saved_to_custom_path():
custom_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "custom")
path = ChromeDriverManager(version="2.26", path=custom_path).install()
path = ChromeDriverManager(version="87.0.4280.88", path=custom_path).install()
assert os.path.exists(path)
assert custom_path in path

Expand Down
6 changes: 3 additions & 3 deletions tests/test_chromium_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable):
"ssl_disabled",
)
driver_path = ChromeDriverManager(
version="83.0.4103.39",
version="87.0.4280.88",
path=custom_path,
chrome_type=ChromeType.CHROMIUM,
).install()
Expand All @@ -22,14 +22,14 @@ def test_driver_with_ssl_verify_disabled_can_be_downloaded(ssl_verify_enable):


def test_chromium_manager_with_specific_version():
bin_path = ChromeDriverManager("2.27", chrome_type=ChromeType.CHROMIUM).install()
bin_path = ChromeDriverManager("87.0.4280.88", chrome_type=ChromeType.CHROMIUM).install()
assert os.path.exists(bin_path)


def test_driver_can_be_saved_to_custom_path():
custom_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "custom")

path = ChromeDriverManager(version="2.27", path=custom_path,
path = ChromeDriverManager(version="87.0.4280.88", path=custom_path,
chrome_type=ChromeType.CHROMIUM).install()
assert os.path.exists(path)
assert custom_path in path
Expand Down
2 changes: 1 addition & 1 deletion tests/test_silent_global_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def log():


def test_chrome_manager_with_specific_version(log):
bin = ChromeDriverManager("2.26").install()
bin = ChromeDriverManager("87.0.4280.88").install()
assert os.path.exists(bin)
15 changes: 14 additions & 1 deletion webdriver_manager/drivers/chrome.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from packaging import version

This comment has been minimized.

Copy link
@yc5

yc5 Oct 19, 2022

Contributor

#454 dependency "packaging" used without definition in pipfile

This comment has been minimized.

Copy link
@aleksandr-kotlyar

aleksandr-kotlyar Oct 19, 2022

Collaborator

Does it cause the import problem in 3.8.4?

This comment has been minimized.

Copy link
@yc5

yc5 Oct 19, 2022

Contributor

Yes, it causes ModuleNotFoundError ( No module named 'packaging' ) when executing this line of script from webdriver_manager.drivers.chrome import ChromeDriver.

This comment has been minimized.

Copy link
@aleksandr-kotlyar

aleksandr-kotlyar Oct 20, 2022

Collaborator

thank you, @yc5 !
it seems already has been fixed

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
Expand Down Expand Up @@ -29,10 +30,22 @@ def get_os_type(self):
return os_type

if is_arch(os_type):
return f"{os_type.replace('_m1', '')}_m1"
return "mac_arm64"

return os_type

def get_url(self):
browser_version = self.get_version()
os_type = self.get_os_type()

# For Mac ARM CPUs after version 106.0.5249.61 the format of OS type changed
# to more unified "mac_arm64". For newer versions, it'll be "mac_arm64"
# by default, for lower versions we replace "mac_arm64" to old format - "mac64_m1".
if version.parse(browser_version) < version.parse("106.0.5249.61") :
os_type = os_type.replace("mac_arm64", "mac64_m1")

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

def get_browser_type(self):
return self._browser_type

Expand Down

0 comments on commit dc73f4a

Please sign in to comment.