cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Frequent Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

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

"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

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

6 REPLIES 6
Community Hero

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

"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

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

Community Hero

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

Also, reference this.

 

https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/checking-existence.html#che...


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

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

The suggestion from Robert Martin is good. Only thing I would metion is that the if statement should use a comparison operator with doble == instead of = which is normally an assignment statement.

Frequent Contributor

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

Hi Buddy.. it's working fine

Thank you... thanks a lot

Community Hero

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

Hi,

 

a comparison operator with doble == instead of = which is normally an assignment statement.

JScript is not the only language that exists Smiley Happy

VBScript is used in this thread.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Highlighted
Occasional Contributor

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

Understood. I didn't realises it was VBScript.thread when saw the question in my login page and clicked the link to check the answers as the question was interesting to me. I was not cretisizing in any way.

New Here?
Join us and watch the welcome video: