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)
| 443 | """ |
| 444 | |
| 445 | def start_session(self, capabilities: dict) -> None: |
| 446 | """Creates a new session with the desired capabilities. |
| 447 | |
| 448 | Args: |
| 449 | capabilities: Either a flat capabilities dict (from a single options |
| 450 | object) or an already-formed W3C ``{"capabilities": {...}}`` object |
| 451 | (produced by ``create_matches`` when a list of options is supplied). |
| 452 | """ |
| 453 | remote_url = self._remote_url() |
| 454 | inner = capabilities.get("capabilities") |
| 455 | if isinstance(inner, dict) and ("alwaysMatch" in inner or "firstMatch" in inner): |
| 456 | caps = copy.deepcopy(capabilities) |
| 457 | if remote_url: |
| 458 | caps["capabilities"].setdefault("alwaysMatch", {})["se:remoteUrl"] = remote_url |
| 459 | else: |
| 460 | if remote_url: |
| 461 | capabilities = {**capabilities, "se:remoteUrl": remote_url} |
| 462 | caps = _create_caps(capabilities) |
| 463 | try: |
| 464 | response = self.execute(Command.NEW_SESSION, caps)["value"] |
| 465 | self.session_id = response.get("sessionId") |
| 466 | self.caps = response.get("capabilities") |
| 467 | except Exception: |
| 468 | if hasattr(self, "service") and self.service is not None: |
| 469 | self.service.stop() |
| 470 | raise |
| 471 | |
| 472 | def _remote_url(self) -> str | None: |
| 473 | """The address used to reach the Grid, advertised as ``se:remoteUrl`` (None for local drivers).""" |
no test coverage detected