Esempio n. 1
0
 async def dispatchEvent(
     self, selector: str, type: str, eventInit: Dict = None, timeout: int = None
 ) -> None:
     await self._channel.send(
         "dispatchEvent",
         dict(selector=selector, type=type, eventInit=serialize_argument(eventInit)),
     )
Esempio n. 2
0
 async def evaluateHandle(self,
                          expression: str,
                          arg: Serializable = None,
                          force_expr: bool = None) -> JSHandle:
     return from_channel(await self._channel.send(
         "evaluateExpressionHandle",
         dict(
             expression=expression,
             isFunction=not (force_expr),
             arg=serialize_argument(arg),
         ),
     ))
Esempio n. 3
0
 async def evaluate(self,
                    expression: str,
                    arg: Serializable = None,
                    force_expr: bool = None) -> Any:
     if not is_function_body(expression):
         force_expr = True
     return parse_result(await self._channel.send(
         "evaluateExpression",
         dict(
             expression=expression,
             isFunction=not (force_expr),
             arg=serialize_argument(arg),
         ),
     ))
Esempio n. 4
0
 async def call(self, func: FunctionWithSource) -> None:
     try:
         frame = from_channel(self._initializer["frame"])
         source = dict(context=frame._page.context, page=frame._page, frame=frame)
         func_args = list(map(parse_result, self._initializer["args"]))
         result = func(source, *func_args)
         if asyncio.isfuture(result):
             result = await result
         await self._channel.send("resolve", dict(result=serialize_argument(result)))
     except Exception as e:
         tb = sys.exc_info()[2]
         asyncio.create_task(
             self._channel.send("reject", dict(error=serialize_error(e, tb)))
         )
Esempio n. 5
0
 async def evalOnSelectorAll(self,
                             selector: str,
                             expression: str,
                             arg: Any = None,
                             force_expr: bool = False) -> Any:
     return parse_result(await self._channel.send(
         "evalOnSelectorAll",
         dict(
             selector=selector,
             expression=expression,
             isFunction=not (force_expr),
             arg=serialize_argument(arg),
         ),
     ))
Esempio n. 6
0
 async def evaluateHandle(self,
                          expression: str,
                          arg: Any = None,
                          force_expr: bool = False) -> JSHandle:
     if not is_function_body(expression):
         force_expr = True
     return from_channel(await self._channel.send(
         "evaluateExpressionHandle",
         dict(
             expression=expression,
             isFunction=not (force_expr),
             arg=serialize_argument(arg),
         ),
     ))
Esempio n. 7
0
 async def waitForFunction(
     self,
     expression: str,
     arg: Serializable = None,
     force_expr: bool = None,
     timeout: int = None,
     polling: Union[int, Literal["raf"]] = None,
 ) -> JSHandle:
     if not is_function_body(expression):
         force_expr = True
     params = locals_to_params(locals())
     params["isFunction"] = not (force_expr)
     params["arg"] = serialize_argument(arg)
     return from_channel(await self._channel.send("waitForFunction", params))
 async def send(self, method: str, params: Dict = None) -> Dict:
     payload = {"method": method}
     if params:
         payload["params"] = serialize_argument(params)["value"]
     result = await self._channel.send("send", payload)
     return parse_result(result)
 async def dispatchEvent(self, type: str, eventInit: Dict = None) -> None:
     await self._channel.send(
         "dispatchEvent", dict(type=type, eventInit=serialize_argument(eventInit))
     )