This is a migrated thread and some comments may be shown as answers.

WPF. Access window that was Hidden.

7 Answers 425 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anna
Top achievements
Rank 1
Anna asked on 02 May 2017, 10:51 AM

Hi,

can you help me to find solution for my case?

I have attached an example. 

My application has 3 windows - 2 are visible, and one has Visibility = Hidden.

By WpfApplication.Windows.Count i can get 2 visible windows. But after my third window become Visible the count is still 2. 

I can see two ways to pass this problem:

1) refresh WpfApplication, like WpfApplication.MainWindow.RefreshVisualTrees() but for the entire application;

2) initialize WpfApplication after my window will be Visible, i.e. connect through the processID.

The problem is that i was not able to find the way to implement any of this options. 

Can you suggest something?

7 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 04 May 2017, 01:35 PM
Hello Anna,

Thanks for all details provided. 

I reviewed the example provided along with the information you shared. However I do not see how the provided application makes the third window visible. 

Therefore I created a sample app based on the one you sent. The only difference is that a button is added to one of the visible windows which changes the visibility of the third hidden window. When recording a test against that application once the third window appears the recorder detects it and attaches to it. 

Please find attached the sample application described above and give it a try. I hope it will be a good example for your query. 

Thanks! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Anna
Top achievements
Rank 1
answered on 04 May 2017, 02:13 PM

Hi Elena, thank you for your example. In mine i changed parameter for window in Snoop.

Sorry if i post this in wrong forum, but i'm not using recorder, i'm using Telerik Testing Framework 2015.3.1015.

I build your application and created a small test:

        [Test]
        public void Test()
        {
            WpfApplication app = Manager.LaunchNewApplication(@"c:\Users\aba\Downloads\WpfApplication2\WpfApplication2\bin\Debug\WpfApplication2.exe");

            Assert.IsTrue(false);
        }

I have break point on Assert.IsTrue(false); and start to debug test.

In Immediate Window in Visual studio after hit break point i call:

app.Windows.Count;

which return me 2. 

After that I click on button and i can see that Window2_test now is visible. So i call again in Immediate Window :

app.Windows.Count.

But it still return count - 2 for me.

It mean that i can't search elements under window 2 which is now visible.

0
Elena
Telerik team
answered on 09 May 2017, 12:30 PM
Hi Anna,

Thank you for getting back to me. 

I tested your scenario on my end and found out that the third window is not successfully detected as you reported. Therefore I submitted a bug report to our feedback portal on your behalf. Here you could find it and follow its progress, comment and vote for it. 

Thank you once again for your cooperation and understanding! 

Regards,
Elena Tsvetkova
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Anna
Top achievements
Rank 1
answered on 09 May 2017, 01:52 PM
Thank you, Elena.
0
Elena
Telerik team
answered on 11 May 2017, 01:29 PM
Hi Anna,

You are welcome. Please follow the progress of the issue from the previously provided link. Hopefully a fix will be soon introduced. 

Regards,
Elena Tsvetkova
Telerik by Progress
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Anna
Top achievements
Rank 1
answered on 01 Jun 2017, 08:24 AM

Hi Elena, i got a reply on ticket and i think we confusing little bit each other. 

In question on feedback portal and in answer you are using "Manager.ActiveApplication.Windows". Yes, proposed solution works with this approach. But it looks suspicious when in tests you are working with two WPF applications.

In my tests i have 2 applications that interact with each other and share activity between each other. 

So, i don't know which exactly application will be ActiveApplication in each moment of time, i also not sure what will be a sequence of starting applications. That's why i want to have variable for first application and for second and use this variable in code instead of using ActiveApplication, like it was in my example - app.Windows.Count. 

Does it make sense for you? 

0
Elena
Telerik team
answered on 05 Jun 2017, 01:48 PM
Hello Anna,

Thank you for your time and feedback. 

I suspect that we are a bit lost in communication. You initially was talking about active windows and as of the latest reply it turns out that you have two applications which should be tested together. At least this is what I understood.

Since the automation scenario you would like to automate is not a straight forward one it is easier to get misunderstood. Would it be possible to prepare a sample applications that will replicate the scenario you experience problems with? It is not required to be something complex but to demonstrate the behavior you observe using the application under test along with a sample test with the used approach. 

I would like to better understand the requirements and scenario to cover to be able to provide further advice. 

Thanks in advance for your understanding! 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Anna
Top achievements
Rank 1
Answers by
Elena
Telerik team
Anna
Top achievements
Rank 1
Share this question
or