Can we add our own code once recording is over?

Ask general questions here.
naga.soft2004
Posts: 4
Joined: Wed Sep 03, 2008 4:19 pm

Can we add our own code once recording is over?

Post by naga.soft2004 » Wed Sep 03, 2008 4:27 pm

Hi,

We want to do automation for C# windows screens. We have studied that Ranorex can be used to automate the GUI for C# also.

In this regard, we want one clarification. Suppose, I have kept Ranorex in record mode and did our recording. After recording is done, I want add some messages n some other stuff in to the generated files. Is it possible to do? Will ranorex supports that?

Please clarify. Also please let us know for automating windows GUI, which one we can go for? Professional or Premium? Please let us know which one is best?

Regards,
Nagaraju

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

Post by Support Team » Thu Sep 04, 2008 11:53 am

Hi Nagaraju,

You can edit and adopt the code files generated by Ranorex Recorder within Ranorex Studio or within (if you have) your own development environment like Visual Studio.

In comparison to Ranorex Professional edition the Ranorex Premium edition contains Ranorex Studio (with integrated Ranorex Recorder). Moreover a stand alone Ranorex Recorder is also available with the Ranorex Premium edition. In future Ranorex Premium will always be a package including additional tools to enhance and to ease test automation development. Ranorex Professional covers all required base library functionality required for execution.

best regards,

Christoph,
Ranorex Support Team

naga.soft2004
Posts: 4
Joined: Wed Sep 03, 2008 4:19 pm

Can we add our own code once recording is over?

Post by naga.soft2004 » Thu Sep 04, 2008 2:02 pm

Hi Christoph,

Thanks for the reply.

But I had a problem yesterday when I was working with Ranorex.
I opened Studio and kept in recording mode. After that I opened a calculator and did an addition on 2 numbers. Then I stopped recording.

After the .cs code generated, I added a message box with a simple message. When I was running, it gave me an error. When I removed that message box part, it is executing fine.

So can you give me an example, where I can add my own code once Recording part is over and when I am playing back, it should display the message box.

Can you also tell me, how to generate the exe once I add my own code.

Thanks in advance.

Once again thanks for the quick reply.

Regards,
Nagaraju

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

Post by Support Team » Thu Sep 04, 2008 3:24 pm

Hi Nagaraju,

You started a new Ranorex project similar to the Ranorex Calculator. Am I right? The message box show method requires the System.Windows.Forms namespace. I suppose you get a compiler error, because of the class name conflict between Ranorex.Applications and Forms.Applications. So could you please add the 'Ranorex' namespace at that point within your code where ErrorAsException is set to true like this:

Code: Select all

Ranorex.Application.ErrorAsException = true;
After that you should be able to compile and to execute your test code.

kind regards,

Christoph,
Ranorex Support Team

naga.soft2004
Posts: 4
Joined: Wed Sep 03, 2008 4:19 pm

Can we add our own code once recording is over?

Post by naga.soft2004 » Thu Sep 04, 2008 3:45 pm

Hi Christoph,

Thanks again for a quick reply.

This time I did not created a new application. I opened Ranorex studio and opened sample calculator automation, which is defaultly installed.

In that, in program.cs file, I have added name System.Windows.Forms and in test1() method, I have added MessageBox.Show("Hi") statement.

It is having
using Ranorex;
Application.ErrorAsException = true; statements.

Once I compile it, it is showing following errors.

Error CS0104: 'Application' is an ambiguous reference between 'System.Windows.Forms.Application' and 'Ranorex.Application'

Error CS0117: 'System.Windows.Forms.Application' does not contain a definition for 'ErrorAsException'

And there are total 26 errors.

Please help me in this regard.

Regards,
Nagaraju

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

Post by Support Team » Fri Sep 05, 2008 10:20 am

You might want to read some tutorial on C# namespaces.

In both the System.Windows.Forms and the Ranorex namespaces there exists a class Application. That's why there is a conflict. So, if you use any of the Application classes, you must specify which one by writing the namespace in front of it, e.g.:

Code: Select all

Ranorex.Application.ErrorAsException = true;
System.Windows.Forms.Application.Exit();
Regards,
Alex
Ranorex Support Team

naga.soft2004
Posts: 4
Joined: Wed Sep 03, 2008 4:19 pm

Can we add our own code once recording is over?

Post by naga.soft2004 » Fri Sep 05, 2008 3:19 pm

Hi Alex,

Thanks for a quick reply. Ya, its working fine.

Regards,
Nagaraju