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

in ExecuteScript_Sandbox command, we define custom javascript objects with properties that we call in our UiVision sequence, for instance:
var testObject = {};
testObject.testdata = “this is test data”;
testObject.testdata2 = “this is another data”;
testObject.testdata3 = “this is another data again”;

return testObject;

then we use these objects in manner
${testObject.testdata}

in latest UiVision release this returns undefined, althoug calling ${testObject} returns all properties values separated with comma:

  • [info] Executing: | echo | ${testObject} | |

  • [echo] this is test data,this is another data,this is another data again

  • [info] Executing: | echo | ${testObject.testdata2} | |

  • [echo] undefined

Tested this and get same outcome in firefox - UI 9.1.9 seems like they are getting turned into an array instead as a workaround you could call the array number ${TESTOBJECT[2]} or use an older version of Ui.V if it was working before. Ill add what code i tested with below.


{
  "Name": "test for",
  "CreationDate": "2024-5-7",
  "Commands": [
    {
      "Command": "comment",
      "Target": "Test 1",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "var testObject = {};\ntestObject.testdata = 'this is test data';\ntestObject.testdata2 = 'this is another data';\ntestObject.testdata3 = 'this is another data again';\nreturn testObject;",
      "Value": "testObject",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${testObject}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${testObject.testdata2}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${TESTOBJECT[2]}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "comment",
      "Target": "Test 2",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "return { name: 'John', age: 30 };",
      "Value": "person",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "${person.name}",
      "Value": "",
      "Description": ""
    }
  ]
}

Logs

  • Playing macro test for

  • [info]

Executing: | comment | Test 1 | |

  • [info]

Executing: | executeScript_Sandbox | var testObject = {}; testObject.testdata = ‘this is test data’; testObject.testdata2 = ‘this is another data’; testObject.testdata3 = ‘this is another data again’; return testObject; | testObject |

  • [info]

Executing: | echo | ${testObject} | |

  • [echo]

this is test data,this is another data,this is another data again

  • [info]

Executing: | echo | ${testObject.testdata2} | |

  • [echo]

undefined

  • [info]

Executing: | echo | ${TESTOBJECT[2]} | |

  • [echo]

this is another data again

  • [info]

Executing: | comment | Test 2 | |

  • [info]

Executing: | executeScript_Sandbox | return { name: ‘John’, age: 30 }; | person |

  • [info]

Executing: | echo | ${person.name} | |

  • [echo]

undefined

  • [info]

Macro completed (Runtime 2.84s)

We are looking into it.

1 Like

hello, any progress while debugging this issue? Unfortunatelly, our automation logic relies significantly on this reported concept and therefore we cannot perform regression/functional tests for our browser-based applications. Thanks in advance…

Hi, the ticket is on our todo list for the next release. So if all goes as planned we will have a fix for this within the next 1-2 weeks.

1 Like

Just a quick status update. The next update will fix this issue as follows:

With this fix echo “Target”: “${testObject.testdata2}” and other multilevel nested objects will work.

However, echoing “Target”: “${testObject}” (still) throws an error as only string, number, boolean types are accepted for echoing. This is by design.

Hello, I would like to know, when will be the new update, please? Thank you.

Thanks for your patience. This is fixed now in the new release (V9.2.2).

1 Like