cancel
Showing results for 
Search instead for 
Did you mean: 

how to check if an object is exits?

New Contributor

how to check if an object is exits?

I want to check if an object exists to check the page is displayed and access the object.

 

when the page is not displayed,  label in below code trowing exception and coming out, I have tried to check whether it is NULL before assigning to label, even that didn't work. how can this be achieved?

 

IDriver driver = new LocalDriver();

IWPFPopupMenuOwner label = driver.Find<IProcess>(new ProcessPattern() { ProcessName = "*****"
.Find<ITopLevelWindow>(new WinFormsPattern() { WinFormsControlName = "******" })
.Find<IWindow>(new WinFormsPattern() { ClrFullClassName = "System.Windows.Forms.MdiClient", WndCaption = "" })
.Find<ITopLevelWindow>(new WinFormsPattern() { WinFormsControlName = "****" })
.Find<IWindow>(new WinFormsPattern() { WinFormsControlName = "******" })
.Find<IWindow>(new WinFormsPattern() { WinFormsControlName = "*****" }
.Find<IWindow>(new WinFormsPattern() { WinFormsControlName = "*******" })
.Find<IWindow>(new WinFormsPattern() { WinFormsControlName = "*****" })
.Find<IWPFPopupMenuOwner>(new WPFPattern() { ClrFullClassName = "System.Windows.Documents.AdornerDecorator" }, 2)
.Find<IWPFPopupMenuOwner>(new WPFPattern() { WPFControlName = "****" }, 7);

1 REPLY 1
Community Hero

Re: how to check if an object is exits?

Hi,

 

As per https://support.smartbear.com/testleft/docs/using/creating-tests/searching-for-objects.html, .Find() method fails if the sought for object cannot be found. .TryFind() complimentary one should be used when the target object may not exist (yet).

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/
================================