Forum Discussion
TanyaYatskovska
Alumni
11 years agoHi Cdichoso,
I’ve found out that TestComplete 11 returns undefined for EvaluateXPath when nothing was found on a page. Although, according to our documentation, it should report null. I’ve reported this behavior to our R&D team so that they could investigate it.
To avoid this error, you need to use isEmpty function instead of isNull to check if some objects were found on your page opened in Chrome. Here is the modified code:
Sub Test5()
Dim page, arr, i
Set page = Sys.Browser("*").Page("*")
arr = page.EvaluateXPath("//INPUT[contains(@name, 'CardNumber')]")
If not isEmpty(arr) Then
arr(i).SetText("X")
Else
Log.Error "Nothing was found."
End If
End Sub