Forum Discussion

bgak2016's avatar
bgak2016
New Contributor
8 years ago

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);