how to check if an object is exits?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).
/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
================================
