internal Task <JsonElement?> EvaluateExpressionAsync( string script, bool isFunction, object arg, bool serializeArgument = false) { JsonSerializerOptions serializerOptions; if (serializeArgument) { serializerOptions = JsonExtensions.GetNewDefaultSerializerOptions(false); arg = new EvaluateArgument { Handles = new List <EvaluateArgumentGuidElement>(), Value = arg, }; serializerOptions.Converters.Add(new EvaluateArgumentConverter()); } else { serializerOptions = Connection.GetDefaultJsonSerializerOptions(false); } return(Connection.SendMessageToServerAsync <JsonElement?>( Guid, "evaluateExpression", new Dictionary <string, object> { ["expression"] = script, ["isFunction"] = isFunction, ["arg"] = arg, }, serializerOptions: serializerOptions)); }
internal Task <JSHandleChannel> WaitForFunctionAsync( string expression, bool isFunction, object arg, bool isPage, int?timeout, int?polling, bool serializeArgument = false) { JsonSerializerOptions serializerOptions; if (serializeArgument) { serializerOptions = JsonExtensions.GetNewDefaultSerializerOptions(false); arg = new EvaluateArgument { Handles = new List <EvaluateArgumentGuidElement>(), Value = arg, }; serializerOptions.Converters.Add(new EvaluateArgumentConverter()); } else { serializerOptions = Connection.GetDefaultJsonSerializerOptions(false); } var args = new Dictionary <string, object> { ["expression"] = expression, ["isFunction"] = isFunction, ["arg"] = arg, ["isPage"] = isPage, }; if (timeout != null) { args["timeout"] = timeout; } if (polling != null) { args["pollingInterval"] = polling; } return(Connection.SendMessageToServerAsync <JSHandleChannel>( Guid, "waitForFunction", args, serializerOptions: serializerOptions)); }
internal Task <JsonElement?> EvalOnSelectorAllAsync(string selector, string script, bool isFunction, EvaluateArgument arg, bool isPage) => Connection.SendMessageToServerAsync <JsonElement?>( Guid, "evalOnSelectorAll", new Dictionary <string, object> { ["selector"] = selector, ["expression"] = script, ["isFunction"] = isFunction, ["arg"] = arg, ["isPage"] = isPage, });
internal Task <JsonElement?> EvaluateExpressionAsync(string script, bool isFunction, EvaluateArgument arg) => Connection.SendMessageToServerAsync <JsonElement?>( Guid, "evaluateExpression", new Dictionary <string, object> { ["expression"] = script, ["isFunction"] = isFunction, ["arg"] = arg, });
internal EvaluateArgumentValueConverter(EvaluateArgument parentObject) { _parentObject = parentObject; }