Testing the Windows application by calling in the Ranorex

Ask general questions here.
ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Testing the Windows application by calling in the Ranorex

Post by ThN » Wed Nov 28, 2012 5:43 pm

Hi,
I am currently facing following problem

1) Should I always need *.exe file to perform Ranorex test.
2) Can I add a control to the form and call form.Show() in the testModule of Ranorex and perform some tests on it. If so how to perform this. Main target is to perform some ranorex test to controls alone by adding them to form and executing it in Ranorex by form.show().

Kind regards,
ThN

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Testing the Windows application by calling in the Ranorex

Post by Support Team » Thu Nov 29, 2012 11:13 am

Hi,

I am not sure I completely got your question.
Could you rephrase it?

You can also execute your tests in Ranorex Studio, just click on the RUN button.
As with other development environments an executable will be automatically generated if you start or build your project.
If you want to perform several actions on different controls of your application I would track them with the Spy tool and perform the actions on the Repository elements, or you could also use the Ranorex Recorder to generate a test script.
Please take a look at our online UserGuide, there you will see how Ranorex works: User Guide.

Regards,
Markus
.
Image

ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Re: Testing the Windows application by calling in the Ranorex

Post by ThN » Fri Nov 30, 2012 2:46 pm

Hi Markus,

Thanks for the reply.
I have already used Ranorex for testing few Windows application. In all my earlier tests I use an executable *.exe. Run the application and then perform the testing operation. But now my problem is that I want to make a ranorex test for each of the individual sub controls (Views). For example if a windows application consists of several views, Now I want to test each individual view seperately.

Each View is a UserControl which I will add them to System.Form (Form.Control.Add(View)) and then show this form as Form.Show(). Now I have to perform tests on this form but I am unable to perform any action on this. Below you can see the Code example:

Code: Select all

 void ITestModule.Run()
        {
            Mouse.DefaultMoveTime = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor = 1.0;
            
            // Initialize an UserControl to be tested
            System.Windows.Forms.UserControl myUserControl = new System.Windows.Forms.UserControl();
            // Initialize form
            System.Windows.Forms.Form testForm = new System.Windows.Forms.Form();
            // Add userControl to the form
            testForm.Controls.Add(myUserControl);
            //show form
            testForm.Show();
            //Now get sub gui elements of the usercontrol
            Table nListView = "/form[@controlname='myUserControl']/container/container[@controlname='panel2']/container/element/container/container/container/container/container[@controlname='panel1']/element/table[@controltypename='NListView']";
            // perform operation on this GUIelement
            nListView.Click();
        }

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Testing the Windows application by calling in the Ranorex

Post by Support Team » Mon Dec 03, 2012 10:50 am

Hi,

I wouldn't create the forms and the tests in one file.
This is not recommended.
I would separate them, is there any particular reason why you make it in one file?

Regards,
Markus
.
Image

ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Re: Testing the Windows application by calling in the Ranorex

Post by ThN » Thu Dec 20, 2012 2:20 pm

Hi Markus,

Thanks for your replay. The reason why I required is that I have many UserControls which I then club them to one View of the tool. But I wished to test individual userControl ranter then entire view in the tool.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Testing the Windows application by calling in the Ranorex

Post by Support Team » Thu Dec 20, 2012 2:43 pm

Your code won't work because the Ranorex automation is executed on the same thread that your user controls runs on. In other words, your user control cannot respond to the Ranorex automation since Ranorex currently uses the thread.
You need to run the automation in a separate thread, or better in another process.

You can still test individual controls, that's just a matter of separating the test cases :D

Regards,
Alex
Ranorex Team
.
Image

ThN
Posts: 15
Joined: Fri Jun 15, 2012 2:12 pm

Re: Testing the Windows application by calling in the Ranorex

Post by ThN » Wed Jan 02, 2013 1:37 pm

Hi,

Thanks for the replay. In reference to the below example, I also tried using Form.ShowDialog() which works if the form has no control inside. If I add a control(userControl) to the form and then perfom Form.ShowDialog, it throws an error "Cross-thread operation not valid: Control 'ProgressForm' accessed from a thread other than the thread it was created on."

The main aim is to test the individual usercontrols during development. But now I have to wait untill complete developement of the tool, so that I will have an *.exe to test.

Thanks for your support, currently I am following a method of creating a demo Form for individual views for testing where I dont have to wait for the development of complete tool.

Kind regards,
ThN

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Testing the Windows application by calling in the Ranorex

Post by Support Team » Wed Jan 02, 2013 4:23 pm

Hi,

You're welcome!
The main aim is to test the individual user controls during development. But now I have to wait until complete development of the tool, so that I will have an *.exe to test.
You can use the same user control specific code which you used in your Ranorex project in a separate C# project.
The only differences are that you have to build the project and execute the generated exe before you can test the controls.

Regards,
Markus
.
Image