Example #1
0
 async def new_session(self, browser: Browser, bind="") -> Session:
     status, response = await self.connection.request(
         url="/session",
         method="POST",
         data={"desiredCapabilities": browser.capabilities},
     )
     original_response = response
     if "sessionId" not in response:
         response = response["value"]
     if "sessionId" not in response:
         if "error" in original_response:
             err_resp = original_response
         elif "error" in response:
             err_resp = response
         else:
             raise SessionStartError("Unknown", "Unknown", original_response)
         raise SessionStartError(
             err_resp["error"], err_resp.get("message", ""), original_response
         )
     session_id = response["sessionId"]
     session = browser.session_class(
         connection=self.connection.prefixed(f"/session/{session_id}"),
         bind=bind,
         wait=self.wait,
         driver=self,
         browser=browser,
     )
     session._check_response_error(status, response)
     return session
Example #2
0
 async def new_session(self, browser: Browser, bind='') -> Session:
     status, response = await self.connection.request(
         url='/session',
         method='POST',
         data={'desiredCapabilities': browser.capabilities},
     )
     if 'sessionId' not in response:
         response = response['value']
     session_id = response['sessionId']
     session = browser.session_class(
         connection=self.connection.prefixed(f'/session/{session_id}'),
         bind=bind,
         wait=self.wait,
         driver=self,
     )
     session._check_response_error(status, response)
     return session