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

Keep WPF application open for the next test

7 Answers 210 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Nathan
Top achievements
Rank 1
Nathan asked on 19 Sep 2012, 09:20 AM
Hi,

I am new to TestStudio and doing the evaluation for one of our WPF application.

I have the following issue in Test Studio.

Opening the application in Test 1, and keep that application open for Test 2 as well when run these tests from Test List sequentially. I don't know how to write the script for this. I am happy to hear if this functionality available in Test Studio

Regards,
Nathan

7 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 19 Sep 2012, 11:14 AM
Hello Nathan,

This ability is not currently available, however it is an existing feature request. You can vote for the PITS Issue here.

In the meantime you can insert each test into a master test via the Test as Step feature.

Regards,
Plamen
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
Elena
Top achievements
Rank 1
commented on 17 Jul 2024, 01:46 PM

My issue is related to the above so can I please have some guidance with the below? 
I have the following scenario: I record a test for Login functionality, a second test that uses the login + additional steps and a 3rd one that uses second test as test step + other steps.
If I put all these 3 tests in a list and run it it will result in doing the login and other common steps 2 or 3 times. What I want is to have the 3 test still separated in the project for easy maintenance, but when running these from the list to only execute the common steps once. Is this possible?  
Elena
Telerik team
commented on 22 Jul 2024, 12:10 PM

Hi Elena, 

The matter seems to be related to test organization. From what you describe the 3rd test is a complete scenario which reuses some common actions. What is the reason to include tests 1 and 2 and not use only test 3 as part of the test list? 

Otherwise any test included in the test list will be executed during the run. If you don't need it, you can exclude it from the list.

I hope this helps.

Regards,
Elena Tsvetkova

0
Nathan
Top achievements
Rank 1
answered on 19 Sep 2012, 03:05 PM
Hi Plamen,

Thanks for the information, Your work around helped me. Could you please tell me how to launch the application by using coding rather than launching the application from the Configure window. How to stop closing the application in end of the Test run?

Regards
Nathan
0
Plamen
Telerik team
answered on 24 Sep 2012, 03:22 PM
Hello Nathan,

The problem here is that Test Studio internally calls the LaunchNewApplication() and ActiveApplication.Quit() methods automatically. If you really want to start the application with code instead of using the Configure window, you can use one of the following methods.
  1. Create a Unit test or convert your existing test to a Unit test using the "Convert All Steps To Code" feature. The disadvantages of this are that a unit test cannot be converted back to a Test Studio test and you have to do all the work using code.
  2. Create a mock application to feed to Test Studio. Then insert a coded step as the first step of the test. Use the following code which closes the mock application and launches the desired application.
//Close the mock application
ActiveApplication.Quit();
 
//Launch an application of your choice
Manager.LaunchNewApplication(@"C:\Release\PhotoDemo.exe");
 
//Refresh Visual Tree
Manager.ActiveApplication.MainWindow.RefreshVisualTrees();

To stop the application from closing:
  1. Select the last step from a Test Studio test and set the Pause Test Step Property to After. This will pause the test after that step leaving the app opened. 
  2. If you are using a Unit test, simply don't use the ActiveApplication.Close() method at the end of the test.

 

Just out of curiosity, why do you need this? How does it help your test automation?


All the best,

Plamen
the Telerik team
Are you enjoying Test Studio? We’d appreciate your vote in the ATI automation awards.
Vote now
0
Abc
Top achievements
Rank 1
answered on 29 Aug 2014, 09:16 AM
Hi Plamen,

I have a question related to active application open and close. The scenario is that I am creating two coded steps in a single WPF test file.
In first coded step, I opened the application through manager.activeapplication , then a scenario in it and then close the app through  wpfApp.MainWindow.Window.Close();  
Now in my next coded step , I again want to open this application for some different scenario but neither manager.activeapplication nor manager.launchnewapplication is working.

Please suggest how to achieve that. Below is the code: 


public class WpfTest1 : BaseWebAiiTest
    {
        #region [ Dynamic Applications Reference ]

        private Applications _applications;

        /// <summary>
        /// Gets the Applications object that has references
        /// to all the elements, windows or regions
        /// in this project.
        /// </summary>
        public Applications Applications
        {
            get
            {
                if (_applications == null)
                {
                    _applications = new Applications(Manager.Current);
                }
                return _applications;
            }
        }

        #endregion

        [CodedStep(@"Open a Station in a casino for a new game day")]
        public void WpfTest1_CodedStep()
        {

            WpfApplication wpfApp = Manager.ActiveApplication;
            Assert.IsTrue(wpfApp.GetWindow("Warnung") != null);

            Button Ok = (wpfApp.GetWindow("Warnung").Find.ByName<Button>("OK"));

            Ok.User.Click();
            Thread.Sleep(1000);

            Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);

            var row = wpfApp.MainWindow.Find.ByName<DataGrid>("Stations");
            var rows = row.RowElements;
            
            var availableRow = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains("Offnen"));

            if (rows.Count > 0 && availableRow != null)
            {
                availableRow.User.Click();
                Thread.Sleep(1000);

                wpfApp.MainWindow.Find.ByName<Button>("OpenStation").User.Click();
            }
            else
            {
                wpfApp.MainWindow.Window.Close();

                
             
            }
               
        }

        
        [CodedStep(@"Open an already opened station(samehostname) in a Casino")]
        public void WpfTest1_CodedStep1()
        {
            WpfApplication wpfApp = Manager.LaunchNewApplication(@"E:\Builds\Build_27August2014\Bin");
              Assert.IsTrue(wpfApp.GetWindow("Warnung") != null);

                Button Ok = (wpfApp.GetWindow("Warnung").Find.ByName<Button>("OK"));

                Ok.User.Click();
             Thread.Sleep(1000);

                Assert.IsTrue(wpfApp.MainWindow.Window.Caption != null);

                var row = wpfApp.MainWindow.Find.ByName<DataGrid>("Stations");
                var rows = row.RowElements;

                var availableRow = rows.FirstOrDefault(stationRow => stationRow.TextBlockContent.Contains(Environment.MachineName));
                if (rows.Count > 0 && availableRow != null)
                {
                   availableRow.User.Click();
                    Thread.Sleep(1000);

                    wpfApp.MainWindow.Find.ByName<Button>("OpenStation").User.Click();
                }
                else
                {
                    wpfApp.MainWindow.Window.Close();
                }
        }

    }

}



0
Ivaylo
Telerik team
answered on 03 Sep 2014, 06:51 AM
Hello,

You are updating quite old post and the information in it may not be relevant. However using the latest Test Studio I have replicated your scenario but I am not able to reproduce the problem you are experiencing. Here is a short video demonstration (no audio) how this is working on my end.

Please try updating to the latest version and give it a try.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Chad
Top achievements
Rank 1
answered on 06 Apr 2016, 06:42 PM

Hello,

 

I know this is old... but is it possible to run a test then a second test without application closing now?  If the feature exists... I have not come across it.

Elena
Telerik team
commented on 22 Jul 2024, 11:56 AM

Hi Chad, 

I wanted to step in and add up to my colleague's response - although the feature is not available out of the box, there are a couple of workarounds which you may find useful. Please, find these in this article.

Best,
Elena

0
Ivaylo
Telerik team
answered on 11 Apr 2016, 08:55 AM
Hello Chad,

Unfortunately there is no such functionality to keep an WPF application open.

Thank you for your understanding.

Regards,
Ivaylo
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Nathan
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Nathan
Top achievements
Rank 1
Abc
Top achievements
Rank 1
Ivaylo
Telerik team
Chad
Top achievements
Rank 1
Share this question
or