How to call a methods in another class file

Class library usage, coding and language questions.
Murali4426
Posts: 6
Joined: Tue Apr 24, 2012 3:36 pm

How to call a methods in another class file

Post by Murali4426 » Tue May 29, 2012 12:14 pm

Hi,
please let me know the call a methods in another class file.
please suggest me how to proceed .

I am calling the function in below code:UserCodeModule1.cs
/*
* Created by Ranorex
* User: mk973520
* Date: 5/29/2012
* Time: 3:43 PM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using System.Data;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;

namespace Test_2905
{
/// <summary>
/// Description of UserCodeModule1.
/// </summary>
[TestModule("B7C8302A-67F3-4201-8312-85214B34BFCF", ModuleType.UserCode, 1)]
public class UserCodeModule1 : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public UserCodeModule1()
{
// Do not delete - a parameterless constructor is required!
}

/// <summary>
/// Performs the playback of actions in this module.
/// </summary>
/// <remarks>You should not call this method directly, instead pass the module
/// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
Recording1 obj = new Recording1();
obj.Launch_app();

}
}
}

i am written the method in below class file:

///////////////////////////////////////////////////////////////////////////////
//
// This file was automatically generated by RANOREX.
// Your custom recording code should go in this file.
// The designer will only add methods to this file, so your custom code won't be overwritten.
// http://www.ranorex.com
//
///////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;

using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;

namespace Test_2905
{
public partial class Recording1
{
public void Launch_app()
{
System.Diagnostics.Process.Start("iexplore.exe","http://google.com");
Report.Info("Logged in successfully");
}

private void Init()
{
// Your recording specific initialization code goes here.
}

//private void Init()
//{
// Your recording specific initialization code goes here.
// }
}
}

Thanks in advance.

Thanks,
Murali.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: How to call a methods in another class file

Post by Support Team » Tue May 29, 2012 2:56 pm

Hi,

You want to call the method "Launch_app()" which is located in your Recording from an UserCode Module?
If yes, then it looks quite okay, are you getting an error or wasn't it executed?
Do you have added your UserCode Module to the test suite to execute it?

Regards,
Markus
Ranorex Support Team