First of all, your current code uses the DOM click
method, which does not have a return value, so you need to remove Set foo =
.
The error might be that the jQuery selector did not find any matching objects. Try checking the length
property of the jQuery
function result:
Set links = Aliases.tree.contentDocument.Script.jQuery("li[data-nodeid='sites'] a.openClose")
If links.length > 0 Then
links.click
Else
Log.Error "Object not found."
End If
But actually there's no need to use jQuery here, since TestComplete has the built-in QuerySelector
method:
Set obj = Aliases.tree.QuerySelector("li[data-nodeid='sites'] a.openClose")
If Not obj Is Nothing Then
obj.Click
Else
Log.Error "Object not found."
End If