Need to handle an object when don't exist, so it will not post error in log.
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also, reference this.
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Buddy.. it's working fine
Thank you... thanks a lot
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
/Alex [Community Champion]
____
[Community Champions] 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 Champions]
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 Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
