Create a new Safari driver instance and launch or find a running safaridriver service. Args: options: Instance of Options. service: Service object for handling the browser driver if you need to pass extra details. keep_alive: Whether to configure SafariRe
(
self,
options: Options | None = None,
service: Service | None = None,
keep_alive: bool = True,
)
| 27 | """Controls the SafariDriver and allows you to drive the browser.""" |
| 28 | |
| 29 | def __init__( |
| 30 | self, |
| 31 | options: Options | None = None, |
| 32 | service: Service | None = None, |
| 33 | keep_alive: bool = True, |
| 34 | ) -> None: |
| 35 | """Create a new Safari driver instance and launch or find a running safaridriver service. |
| 36 | |
| 37 | Args: |
| 38 | options: Instance of Options. |
| 39 | service: Service object for handling the browser driver if you need to pass extra details. |
| 40 | keep_alive: Whether to configure SafariRemoteConnection to use HTTP keep-alive. |
| 41 | """ |
| 42 | self.service = service if service else Service() |
| 43 | self.options = options if options else Options() |
| 44 | |
| 45 | self.service.path = self.service.env_path() or DriverFinder(self.service, self.options).get_driver_path() |
| 46 | |
| 47 | if not self.service.reuse_service: |
| 48 | self.service.start() |
| 49 | |
| 50 | executor = SafariRemoteConnection( |
| 51 | remote_server_addr=self.service.service_url, |
| 52 | keep_alive=keep_alive, |
| 53 | ignore_proxy=self.options._ignore_local_proxy, |
| 54 | ) |
| 55 | |
| 56 | try: |
| 57 | super().__init__(command_executor=executor, options=self.options) |
| 58 | except Exception: |
| 59 | self.quit() |
| 60 | raise |
| 61 | |
| 62 | def quit(self): |
| 63 | """Closes the browser and shuts down the SafariDriver executable.""" |
nothing calls this directly
no test coverage detected