Skip to content

Commit

Permalink
Add safari driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Medvedev committed Dec 12, 2023
1 parent 269d5e5 commit dd79cde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions splinter/driver/webdriver/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from splinter.driver.webdriver.setup import _setup_chrome
from splinter.driver.webdriver.setup import _setup_edge
from splinter.driver.webdriver.setup import _setup_firefox
from splinter.driver.webdriver.setup import _setup_safari

# MonkeyPatch RemoteConnection
remote_connection.RemoteConnection._request = patch_request # type: ignore
Expand Down Expand Up @@ -64,5 +65,12 @@ def __init__(

options = options or Options()
driver = _setup_firefox(Remote, self.config, options, **kwargs)
elif browser_name == "SAFARI":
from selenium.webdriver.safari.options import Options

options = options or Options()
driver = _setup_safari(Remote, self.config, options, **kwargs)
else:
raise ValueError(f"Unsupporeted browser {browser_name}")

super().__init__(driver, wait_time)
11 changes: 11 additions & 0 deletions splinter/driver/webdriver/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ def _setup_firefox(driver_class, config=None, options=None, service=None, **kwar
rv.fullscreen_window()

return rv

def _setup_safari(driver_class, config=None, options=None, service=None, **kwargs):
"""
Returns: selenium.webdriver.Safari || selenium.webdriver.Remote
"""
if driver_class == Remote:
rv = driver_class(options=options, **kwargs)
else:
rv = driver_class(options=options, service=service, **kwargs)

return rv

0 comments on commit dd79cde

Please sign in to comment.