OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptInternal C# (CSharp) Method

ExecuteScriptInternal() private method

private ExecuteScriptInternal ( string script, bool async ) : object
script string
async bool
return object
        private object ExecuteScriptInternal(string script, bool async, params object[] args)
        {
            if (!this.Capabilities.IsJavaScriptEnabled)
            {
                throw new NotSupportedException("You must be using an underlying instance of WebDriver that supports executing javascript");
            }

            // Escape the quote marks
            // script = script.Replace("\"", "\\\"");
            object[] convertedArgs = ConvertArgumentsToJavaScriptObjects(args);

            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("script", script);

            if (convertedArgs != null && convertedArgs.Length > 0)
            {
                parameters.Add("args", convertedArgs);
            }
            else
            {
                parameters.Add("args", new object[] { });
            }

            DriverCommand command = async ? DriverCommand.ExecuteAsyncScript : DriverCommand.ExecuteScript;
            Response commandResponse = this.Execute(command, parameters);
            return this.ParseJavaScriptReturnValue(commandResponse.Value);
        }