Hi I am trying to Call or Run a Class from within another Class.
i.e.
Class A
{
Code...
then call Class B
}
Class B
{
Some code
}
Have tried the Run and Call operators but nothing works, does anyone know how this is done?
thanks,
Alina
Run a class from within another Class
Re: Run a class from within another Class
Hi,
I guess you want to call class B methods in class A, right? What you are looking for is called "inheritance". The code should look like this:
I guess you want to call class B methods in class A, right? What you are looking for is called "inheritance". The code should look like this:
Code: Select all
Class A : B
{
MethodB();
}
Class B
{
public MethodB()
{
...
}
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Run a class from within another Class
Thanks Kurtz,
I supose i will need to create a method in Classs B, as it does not have one.
Hey, do you know how i can write some C# code tha would calculate a date and enter it ina date field.
I need to enter a week from today for e.g. but i d o not want to hard-code it as if i do that the test will fail wehn un in 6 months time for eg.
so each time the test it run, the date is entered as a week from today.
Could you shed any light on this?
THnaks,
Alina
I supose i will need to create a method in Classs B, as it does not have one.
Hey, do you know how i can write some C# code tha would calculate a date and enter it ina date field.
I need to enter a week from today for e.g. but i d o not want to hard-code it as if i do that the test will fail wehn un in 6 months time for eg.
so each time the test it run, the date is entered as a week from today.
Could you shed any light on this?
THnaks,
Alina
Re: Run a class from within another Class
Hi,
Here is the code to get the actual date+7 days and convert it to string:
Add a code action with the above code to your recording (before the place where you want to insert the obtained date to the date field).
Then use SetValue >> Text action with assigned $strDate value and assigned date field repo item.
Here is how your recording should look like... Of course, all this could be done without using the recording module (if you prefer this way).
Here is the code to get the actual date+7 days and convert it to string:
Create a new module variable in your recording (e.g. strDate).strDate = System.DateTime.Now.AddDays(7).ToString("dd.MM.yy");
Add a code action with the above code to your recording (before the place where you want to insert the obtained date to the date field).
Then use SetValue >> Text action with assigned $strDate value and assigned date field repo item.
Here is how your recording should look like... Of course, all this could be done without using the recording module (if you prefer this way).
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration