MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ExecuteScriptCommand

Method ExecuteScriptCommand

dotnet/src/webdriver/WebDriver.cs:920–938  ·  view source on GitHub ↗

Executes JavaScript in the context of the currently selected frame or window using a specific command. The JavaScript code to execute. The name of the command to execute. The arguments to the script. The value returned by the script.

([StringSyntax(StringSyntaxConstants.JavaScript)] string script, string commandName, params object?[]? args)

Source from the content-addressed store, hash-verified

918 /// <param name="args">The arguments to the script.</param>
919 /// <returns>The value returned by the script.</returns>
920 protected object? ExecuteScriptCommand([StringSyntax(StringSyntaxConstants.JavaScript)] string script, string commandName, params object?[]? args)
921 {
922 object?[] convertedArgs = ConvertArgumentsToJavaScriptObjects(args);
923
924 Dictionary<string, object?> parameters = new Dictionary<string, object?>();
925 parameters.Add("script", script);
926
927 if (convertedArgs != null && convertedArgs.Length > 0)
928 {
929 parameters.Add("args", convertedArgs);
930 }
931 else
932 {
933 parameters.Add("args", new object[] { });
934 }
935
936 Response commandResponse = this.Execute(commandName, parameters);
937 return this.ParseJavaScriptReturnValue(commandResponse.Value);
938 }
939
940 private static object? ConvertObjectToJavaScriptObject(object? arg)
941 {

Callers 2

ExecuteAsyncScriptMethod · 0.95
ExecuteScriptMethod · 0.95

Calls 3

ExecuteMethod · 0.95
AddMethod · 0.45

Tested by

no test coverage detected