Forum Discussion

cdichoso's avatar
cdichoso
New Contributor
9 years ago

Finding web object doesn't work for Google Chrome

Read this article on the support website: https://support.smartbear.com/viewarticle/75851/

 

As our test script kept failing from using a series or mapped object, we decided to use EvaluateXPath and/or Find methods to lookup the test object and execute certain actions. This solution worked nicely on IE and Firefox but NOT in Chrome. Below is a sample script I am trying to run:

 

Sub Test5()

Dim page, arr, i
Set page = Sys.Browser("*").Page("*")

arr = page.EvaluateXPath("//INPUT[contains(@name, 'CardNumber')]")

If Not IsNull(arr) Then
arr(i).SetText("X")
Else
Log.Error "Nothing was found."
End If
End Sub

 

It returns a "Microsoft VBScript runtime error. Type mismatch: 'arr' ..." error message which I believe is due to the EvaluateXPath being unable to get any value.

 

Is there any better way to find an object on Google Chrome?

 

 

Using:

TestComplete 11.10.1005

Google Chrome 45

4 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi 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
    • cdichoso's avatar
      cdichoso
      New Contributor

      Thank you for forwarding my concern. Please do let me know when this gets resolved or updated from your R&D team.

      Also, thank you for the isEmpty() suggestion. We figured that one as well when the msgbox did not return any value.

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi Cdichoso,

         

        I was informed that this issue would be fixed in one of the next TestComplete version.