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)
| 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 | { |
no test coverage detected