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
Highlighted
Regular 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
Highlighted
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
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available

View solution in original post

6 REPLIES 6
Highlighted
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
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available

View solution in original post

Highlighted
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
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
Highlighted
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.

Highlighted
Regular 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

Highlighted
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 🙂

VBScript is used in this thread.

 

Regards,
  /Alex [Community Hero]
____
[Community Heroes] 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. Posts made by [Community Heroes]
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.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
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:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors