MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / __init__

Method __init__

py/selenium/webdriver/firefox/webdriver.py:38–72  ·  view source on GitHub ↗

Create a new instance of the Firefox driver, start the service, and create new instance. 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 Firefo

(
        self,
        options: Options | None = None,
        service: Service | None = None,
        keep_alive: bool = True,
    )

Source from the content-addressed store, hash-verified

36 CONTEXT_CONTENT = "content"
37
38 def __init__(
39 self,
40 options: Options | None = None,
41 service: Service | None = None,
42 keep_alive: bool = True,
43 ) -> None:
44 """Create a new instance of the Firefox driver, start the service, and create new instance.
45
46 Args:
47 options: Instance of Options.
48 service: Service object for handling the browser driver if you need to pass extra details.
49 keep_alive: Whether to configure FirefoxRemoteConnection to use HTTP keep-alive.
50 """
51 self.service = service if service else Service()
52 self.options = options if options else Options()
53
54 finder = DriverFinder(self.service, self.options)
55 if finder.get_browser_path():
56 self.options.binary_location = finder.get_browser_path()
57 self.options.browser_version = None
58
59 self.service.path = self.service.env_path() or finder.get_driver_path()
60 self.service.start()
61
62 executor = FirefoxRemoteConnection(
63 remote_server_addr=self.service.service_url,
64 keep_alive=keep_alive,
65 ignore_proxy=self.options._ignore_local_proxy,
66 )
67
68 try:
69 super().__init__(command_executor=executor, options=self.options)
70 except Exception:
71 self.quit()
72 raise
73
74 def set_context(self, context) -> None:
75 """Sets the context that Selenium commands are running in.

Callers

nothing calls this directly

Calls 9

get_browser_pathMethod · 0.95
get_driver_pathMethod · 0.95
quitMethod · 0.95
ServiceClass · 0.90
OptionsClass · 0.90
DriverFinderClass · 0.90
startMethod · 0.65
env_pathMethod · 0.45

Tested by

no test coverage detected