WPF. Access window that was Hidden.

8 posts, 0 answers
  1. Anna
    Anna avatar
    4 posts
    Member since:
    Dec 2016

    Posted 02 May 2017 Link to this post

    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?

  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 04 May 2017 Link to this post

    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
     
  3. Anna
    Anna avatar
    4 posts
    Member since:
    Dec 2016

    Posted 04 May 2017 Link to this post

    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.

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 09 May 2017 Link to this post

    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
     
  5. Anna
    Anna avatar
    4 posts
    Member since:
    Dec 2016

    Posted 09 May 2017 Link to this post

    Thank you, Elena.
  6. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 11 May 2017 Link to this post

    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
     
  7. Anna
    Anna avatar
    4 posts
    Member since:
    Dec 2016

    Posted 01 Jun 2017 Link to this post

    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? 

  8. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    934 posts

    Posted 05 Jun 2017 Link to this post

    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
     
Back to Top