Creates a new session with the desired capabilities. Args: capabilities: Either a flat capabilities dict (from a single options object) or an already-formed W3C ``{"capabilities": {...}}`` object (produced by ``create_matches`` when a list of opti
(self, capabilities: dict)
| 377 | pass |
| 378 | |
| 379 | def start_session(self, capabilities: dict) -> None: |
| 380 | """Creates a new session with the desired capabilities. |
| 381 | |
| 382 | Args: |
| 383 | capabilities: Either a flat capabilities dict (from a single options |
| 384 | object) or an already-formed W3C ``{"capabilities": {...}}`` object |
| 385 | (produced by ``create_matches`` when a list of options is supplied). |
| 386 | """ |
| 387 | remote_url = self._remote_url() |
| 388 | inner = capabilities.get("capabilities") |
| 389 | if isinstance(inner, dict) and ("alwaysMatch" in inner or "firstMatch" in inner): |
| 390 | caps = copy.deepcopy(capabilities) |
| 391 | if remote_url: |
| 392 | caps["capabilities"].setdefault("alwaysMatch", {})["se:remoteUrl"] = remote_url |
| 393 | else: |
| 394 | if remote_url: |
| 395 | capabilities = {**capabilities, "se:remoteUrl": remote_url} |
| 396 | caps = _create_caps(capabilities) |
| 397 | try: |
| 398 | response = self.execute(Command.NEW_SESSION, caps)["value"] |
| 399 | self.session_id = response.get("sessionId") |
| 400 | self.caps = response.get("capabilities") |
| 401 | except Exception: |
| 402 | if hasattr(self, "service") and self.service is not None: |
| 403 | self.service.stop() |
| 404 | raise |
| 405 | |
| 406 | def _remote_url(self) -> str | None: |
| 407 | """The address used to reach the Grid, advertised as ``se:remoteUrl`` (None for local drivers).""" |
no test coverage detected