Forum Discussion

kaiiii's avatar
kaiiii
Regular Contributor
5 years ago
Solved

Need to handle an object when don't exist, so it will not post error in log.

I am trying to handle a object that mostly time doesn't exist in application, it giving me error in test log but my execution is continue.

 

"Unable to find the object TextNode(0). See Details for additional information." error is displaying in test log.

Due to this getting test case result as failure. (While whole journey has been completed.)

 

Please check the below code that i am using and tell me how can i handle it.

 

Set Sold = page.Section(2).Panel(0).Panel(1).Panel("shopLastItem").Panel(0).Section(0).Panel(1).Panel(0).Panel(0).TextNode(0)


If (Sold.Exists = True) Then

   'Some kind of logic here

End IF

  • "Exists" is a property of the object.  So, you can't check a property of an object if the object itself does not exist. So, you need to use a slightly different method.  Try this

     

    Set Sold = page.Section(2).Panel(0).Panel(1).Panel("shopLastItem").Panel(0).Section(0).Panel(1).Panel(0).Panel(0).FindChild('ObjectType','TextNode')
    
    If (Sold.Exists = True) Then
    
       'Some kind of logic here
    
    End IF

6 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    "Exists" is a property of the object.  So, you can't check a property of an object if the object itself does not exist. So, you need to use a slightly different method.  Try this

     

    Set Sold = page.Section(2).Panel(0).Panel(1).Panel("shopLastItem").Panel(0).Section(0).Panel(1).Panel(0).Panel(0).FindChild('ObjectType','TextNode')
    
    If (Sold.Exists = True) Then
    
       'Some kind of logic here
    
    End IF