Get window object from xbap application

Aug 5, 2008 at 12:24 PM
Hi, I'm very new to White tool and automation testing and I'm about to ask you a bit dumpy question.
My company is currently adopting the wpf technologie ,we are going to develop an application that can run both as a Web application and as a WinForms type application.
My question is related to  how to get a Window object from an xbap application.

I tried this code:

Window window = application.GetWindow("PrgamaDataGrid", InitializeOption.NoCache);
But when I try and run the code I get a NullReferenceException:
System.NullReferenceException: Object reference not set to an instance of an object

Any advice will be much appreciated.
Coordinator
Aug 6, 2008 at 3:20 PM
Can you send the complete stacktrace as well for this exception message?
Aug 6, 2008 at 8:19 PM

Hi, I apologize.

Actually, it seems that I cannot find the window of the application.

So, here is my code:

Application

 

application = Application.Launch(@"C:\test\TicTacToe\bin\Debug\TicTacToe.xbap");

After this code the browser (IE 7) opens and shows the content of the xbap file.

Now I need to access the window of the application object.
I tried:

 

Window

 

window = application.GetWindow("Page1", InitializeOption.NoCache);

But it says it could not find any window with that name.
Then I tried:

 

Window

 

wnd = application.GetWindows()[0];

but the error was:

Could not find any windows for this application.

Is this the correct way to start testing an XBAP application?
Please point me to the right direction.

Thanks

 

Coordinator
Aug 7, 2008 at 4:07 PM
Seems like Application's processId and window's processId are different.
Can you launch UISpy. Find the window which you are looking for and check whether window has same processId or not.
You can also try using Desktop.Windows() to get all windows on your desktop and find out which one you are interested in.