Ask a Question

Generic way to locate an XBAP in IE

Angshuman
Occasional Contributor

Generic way to locate an XBAP in IE

I am looking for a generic way to locate an XBAP window (a WPF 'Page' class) within the IE window. My problem is that the WPF page might be contained directly within the IE window, or it might be nested within some other control running inside the IE window. I wish to use the same script in either cases (as I have no clue on the exact hierarchy above my XBAP page)



Please take a look at the above screenshot, where the XBAP ('Page1') is a child window inside the 'process("iexplore")' object.  However the following code to locate it doesn't work. The variable 'IE' gets populated correctly, but the next statement results in "The object with the specified attributes does not exist." error.






function FindXBAPWindow()


FindXBAPWindow()

{


var IE,Page1;


 


// Searches for the window


IE = Sys.Process("iexplore");


Page1 = IE.WPFObject("Page1","",1)


 


 


// Processes the search results


if (Page1.Exists)


Log.Message(Page1.FullName);


else


Log.Error("The object was not found.");


 


 


}



Please help me on where I am going wrong.





Thanks in advance.

7 REPLIES 7
Angshuman
Occasional Contributor

PS - I am not sure how so many images got uploaded. Just to tell everybody that they are all identical.
YMinaev
Staff

Hi,



You can use the Find method to do this (see the "Find Method" help topic).
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Angshuman
Occasional Contributor

Hi, I tried

Page1 = IE.Find("Page1");



but it didn't help. Any idea what was wrong?
YMinaev
Staff

Hi,



You're using Find incorrectly. Its first parameter is the property name by which it will search for an object, and the second parameter is the value of this property. You can find information on Find's parameters in the "Find Method" help topic.
------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Angshuman
Occasional Contributor

You are right - I posted it wrongly. The way I am doing it as below:



var IE,Page1;

 var  PropArray = new Array("WndClass");

 var ValuesArray = new Array("Page1");



 

  // Searches for the window

  IE = Sys.Process("iexplore");

 

  Page1 = IE.Find(PropArray,ValuesArray,100)



here 'Page1' is the name of the class as well as the value set to the 'Title' property of the page in xaml.



Basically all I need is to derive WPFObject("Page1","",1) from Process("iexplore") (as per the attached object hierarchy).
YMinaev
Staff

Hi,



First of all, since you're using a single property, there's no need to pass it in an array. You can use strings. Second, try ClrClassName instead of WndClass.

var page = IE.Find("ClrClassName", "Page1", 100);

------
Yuri
TestComplete Customer Care Engineer

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Angshuman
Occasional Contributor

That solves my problem pretty well. Thanks!
cancel
Showing results for 
Search instead for 
Did you mean: