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

Method __init__

py/selenium/webdriver/remote/webdriver.py:299–374  ·  view source on GitHub ↗

Create a new driver instance that issues commands using the WebDriver protocol. Args: command_executor: Either a string representing the URL of the remote server or a custom remote_connection.RemoteConnection object. Defaults to 'http://127.0.0.1:

(
        self,
        command_executor: str | RemoteConnection = "http://127.0.0.1:4444",
        keep_alive: bool = True,
        file_detector: FileDetector | None = None,
        options: BaseOptions | list[BaseOptions] | None = None,
        locator_converter: LocatorConverter | None = None,
        web_element_cls: type[WebElement] | None = None,
        client_config: ClientConfig | None = None,
    )

Source from the content-addressed store, hash-verified

297 _shadowroot_cls = ShadowRoot
298
299 def __init__(
300 self,
301 command_executor: str | RemoteConnection = "http://127.0.0.1:4444",
302 keep_alive: bool = True,
303 file_detector: FileDetector | None = None,
304 options: BaseOptions | list[BaseOptions] | None = None,
305 locator_converter: LocatorConverter | None = None,
306 web_element_cls: type[WebElement] | None = None,
307 client_config: ClientConfig | None = None,
308 ) -> None:
309 """Create a new driver instance that issues commands using the WebDriver protocol.
310
311 Args:
312 command_executor: Either a string representing the URL of the remote
313 server or a custom remote_connection.RemoteConnection object.
314 Defaults to 'http://127.0.0.1:4444'.
315 keep_alive: (Deprecated) Whether to configure
316 remote_connection.RemoteConnection to use HTTP keep-alive.
317 Defaults to True.
318 file_detector: Pass a custom file detector object during
319 instantiation. If None, the default LocalFileDetector() will be
320 used.
321 options: Instance of a driver options.Options class.
322 locator_converter: Custom locator converter to use. Defaults to None.
323 web_element_cls: Custom class to use for web elements. Defaults to
324 WebElement.
325 client_config: Custom client configuration to use. Defaults to None.
326 """
327 if options is None:
328 raise TypeError(
329 "missing 1 required keyword-only argument: 'options' (instance of driver `options.Options` class)"
330 )
331 elif isinstance(options, list):
332 capabilities = create_matches(options)
333 _ignore_local_proxy = False
334 else:
335 capabilities = options.to_capabilities()
336 _ignore_local_proxy = options._ignore_local_proxy
337 self.command_executor = command_executor
338 if isinstance(self.command_executor, (str, bytes)):
339 self.command_executor = get_remote_connection(
340 capabilities,
341 command_executor=command_executor,
342 keep_alive=keep_alive,
343 ignore_local_proxy=_ignore_local_proxy,
344 client_config=client_config,
345 )
346 self._is_remote = True
347 self.session_id: str | None = None
348 self.caps: dict[str, Any] = {}
349 self.pinned_scripts: dict[str, Any] = {}
350 self.error_handler = ErrorHandler()
351 self._switch_to = SwitchTo(self)
352 self._mobile = Mobile(self)
353 self.file_detector = file_detector or LocalFileDetector()
354 self.locator_converter = locator_converter or LocatorConverter()
355 self._web_element_cls = web_element_cls or self._web_element_cls
356 self._authenticator_id = None

Callers

nothing calls this directly

Calls 11

start_clientMethod · 0.95
start_sessionMethod · 0.95
ErrorHandlerClass · 0.90
SwitchToClass · 0.90
MobileClass · 0.90
LocalFileDetectorClass · 0.90
LocatorConverterClass · 0.90
FedCMClass · 0.90
create_matchesFunction · 0.85
get_remote_connectionFunction · 0.85
to_capabilitiesMethod · 0.45

Tested by

no test coverage detected