Skip to content

Commit

Permalink
[#494] NEW: drop webdriver-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
yashaka committed Jan 25, 2024
1 parent d18c753 commit 91ff35a
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 438 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ TODOs:

## 2.0.0rc6 (to be released on ??.01.2024)

### Goodbye python 3.7 and webdriver-manager 👋🏻

* drop py3.7 support + upgrade selenium>=4.12.0
* drop webdriver-manager in favor of Selenium Manager

## 2.0.0rc5 (released on 22.01.2024)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pip install selene

### from sources

GIVEN webdriver and webdriver_manager are already installed
GIVEN webdriver

THEN

Expand Down
39 changes: 1 addition & 38 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ Changelog = "https://github.com/yashaka/selene/releases"
python = "^3.8"
selenium = ">=4.12.0"
future = "*"
webdriver-manager = "==3.8.6"
typing-extensions = ">=4.9.0"

[tool.poetry.dev-dependencies]
Expand Down
66 changes: 12 additions & 54 deletions selene/core/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from selenium.webdriver.common.options import BaseOptions
from selenium.webdriver.common.service import Service

from selene import support
from selene.common import fp, helpers
from selene.common.data_structures import persistent
from selene.common.fp import F
Expand Down Expand Up @@ -63,64 +62,23 @@ def _build_local_driver_by_name_or_remote_by_url_and_options(
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.edge.service import Service as EdgeService # type: ignore

from selene.support._extensions.webdriver_manager import ChromeType # type: ignore

from webdriver_manager.chrome import ChromeDriverManager # type: ignore
from webdriver_manager.firefox import GeckoDriverManager # type: ignore
from webdriver_manager.microsoft import EdgeChromiumDriverManager # type: ignore

def install_and_build_chrome():
# TODO: consider simplifying the logic... to much of ifs
# probably all ifs were already before calling this function
# see example of simplification in install_and_build_firefox
if config.driver_options and not isinstance(
config.driver_options, ChromeOptions
):
raise ValueError(
f'Default config.build_driver_strategy ("driver factory"), '
f'if config.driver_name is set to "chrome", - '
f'expects only instance of ChromeOptions or None'
f'in config.driver_options,'
f'but got: {config.driver_options}'
)

driver_manager = (
support._extensions.webdriver_manager.patch._to_find_chromedrivers_from_115(
ChromeDriverManager(chrome_type=ChromeType.GOOGLE)
)
)

def build_chrome():
return Chrome(
service=config.driver_service or ChromeService(driver_manager.install()),
service=config.driver_service or ChromeService(),
options=config.driver_options,
)

def install_and_build_firefox():
def build_firefox():
return Firefox(
service=config.driver_service
or FirefoxService(GeckoDriverManager().install()),
service=config.driver_service or FirefoxService(),
options=config.driver_options,
)

def install_and_build_edge():
if config.driver_options:
if isinstance(config.driver_options, EdgeOptions):
return Edge(
service=config.driver_service
or EdgeService(EdgeChromiumDriverManager().install()),
options=config.driver_options,
)
else:
raise ValueError(
f'Default config.build_driver_strategy, '
f'if config.driver_name is set to "edge", - '
f'expects only instance of EdgeOptions or None in config.driver_options,'
f'but got: {config.driver_options}'
)
else:
return Edge(
service=config.driver_service or (EdgeChromiumDriverManager().install())
)
def build_edge():
return Edge(
service=config.driver_service or EdgeService(),
options=config.driver_options,
)

def build_remote_driver():
from selenium.webdriver import Remote
Expand Down Expand Up @@ -169,9 +127,9 @@ def build_appium_driver():
)

return { # type: ignore
'chrome': install_and_build_chrome,
'firefox': install_and_build_firefox,
'edge': install_and_build_edge,
'chrome': build_chrome,
'firefox': build_firefox,
'edge': build_edge,
'remote': build_remote_driver,
'appium': build_appium_driver,
}.get(
Expand Down
1 change: 0 additions & 1 deletion selene/support/_extensions/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from . import webdriver_manager
10 changes: 0 additions & 10 deletions selene/support/_extensions/webdriver_manager/__init__.py

This file was deleted.

Loading

0 comments on commit 91ff35a

Please sign in to comment.