예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
 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,
 });
예제 #4
0
 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,
 });
예제 #5
0
 internal EvaluateArgumentValueConverter(EvaluateArgument parentObject)
 {
     _parentObject = parentObject;
 }