executeScript_Sandbox errors on a `null` return value and removes them in an array as return value

Hello,

The executeScript_Sandbox command errors when null is in the return value or just removes them from nested arrays.

On the contrary, executeScript commands handles them just fine.

Test Environment/s
Chrome on Linux with UI.Vision V1.9.5
No XModules installed
Clean Profile (i.e., no other extensions installed, clean cookies and history, all default settings)

Edge on Windows 10 with UI.Vision V1.9.3
No XModules installed

Expected Behavior: Handle and return null as it is done by ExecuteScript
Observed Behavior: Errors on “null” and if returning a nested array removes all null elements within the nested array.

Test Macro:

{
  "Name": "NullStripper",
  "CreationDate": "2024-4-17",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "return [[1,null,3,null,5,null,7,null,9]];",
      "Value": "NS_ARRAY",
      "Description": "This will write a nested array to NS_ARRAY but will remove all nulls and mess up the positions of the elements."
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return [420,69,null];",
      "Value": "",
      "Description": "This line will throw an error."
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return null;",
      "Value": "",
      "Description": "This line will also throw an error"
    }
  ]
}

WORKAROUND:
For now, the workaround on this is to return the JSON wrapped version with JSON.stringify. Then, use JSON.parse to unwrap it on the next executeScript*.

Or, just use the regular executeScript, or avoid having your executeScript_Sandbox commands return null?

Thanks for reporting this issue, I confirmed it and we will try to solve it with the next update.

Background info: For technical reasons executeScript_Sandbox needs to use its own JS interpreter. The non-sandbox executeScript runs inside the web browser and can use the Chrome V8 engine or the Firefox equivalent Spidermonkey.

Thanks again for the useful test case => Fixed in V9.1.9

Hi,

It doesn’t seem to be fixed in v9.1.9. The test macro still errors out the same and removes all nulls within nested arrays.

I do get a new and more descriptive error message than before in v9.1.6, which is nice:
Cannot convert undefined or null to object

Though, given that this is marked solved, is the Sandbox version not meant to handle nulls by design?
Workarounds still apply so it is not much of a problem but I’ll do avoid making the Sandbox version handle nulls directly.

Related issue: Javascript objects: calling ${object.property} returns undefined

I confirmed that the issue is still in V9.1.9. => We will continue to debug it.