inheriting a class give error

Ask general questions here.
sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

inheriting a class give error

Post by sdimbre » Fri Oct 11, 2013 12:55 pm

Hi Team,

This is Dimbre. First of all my sincere appoligies if I am asking anything bad here.

I am doing something like following
Ranorex.WebDocument uname = "/dom[@domain='burjira.dub.usoh.ibm.com:6777' and @caption~'^Issue']";

This do works fine and locates the UI object, but my question here is how is this above code working. Here we are assigning string value object of type Ranorex.WebDocument

I am trying to do similar thing as explained below but it fails

///Created a class named "MyClass" which is child of "Ranorex.WebDocument"
namespace Automation
{
public class MyClass : Ranorex.WebDocument
{
}
}

//Following does not work
MyClass dumObj1 = new MyClass();
dumObj1 = "/dom[@domain='burjira.dub.usoh.ibm.com:6777' and @caption~'^Issue']"; //Here it says 'Cannot implicitly convert type string to Automation.MyClass'.

Requesting you kind assistance here.

Thanks and Regards,
SDimbre

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

Re: inheriting a class give error

Post by Support Team » Tue Oct 15, 2013 5:30 pm

Hi Dimbre,

Is there a special reason why you create a custom class which derives from the "Ranorex.WebDocument" adapter?
Maybe this can be handled in another way?
Can you please explain your use case?

Thanks,
Markus
.
Image

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

Re: inheriting a class give error

Post by Support Team » Tue Oct 15, 2013 6:06 pm

Hello,

It seems that you are missing a few steps (e.g. constructor) in order to inherit this class.
Please take a look at the following links:
Using Constructors in C#
Inheritance and Derived Classes (C# vs Java)
C# - Making all derived classes call the base class constructor

You could find a useful example how to inherit a class in the following post:
http://www.ranorex.com/forum/custom-ran ... html#p4855

Regards,
Markus (T)
.
Image

sdimbre
Posts: 21
Joined: Wed Sep 07, 2011 12:38 pm

Re: inheriting a class give error

Post by sdimbre » Fri Oct 18, 2013 5:05 pm

Hi Markus,
Thanks for the reply.
By doing this I can add my own specific behavior for method provided by this class. And Same way I can do for other classes also.
But as explained stuck in first phase and not able to implement further.

///Created a class named "MyClass" which is child of "Ranorex.WebDocument"
namespace Automation
{
public class MyClass : Ranorex.WebDocument
{
}
}

//Following does not work
MyClass dumObj1 = new MyClass();
dumObj1 = "/dom[@domain='burjira.dub.usoh.ibm.com:6777' and @caption~'^Issue']"; //Here it says 'Cannot implicitly convert type string to Automation.MyClass'.

Thanks,
SDimbre


Support Team wrote:Hi Dimbre,

Is there a special reason why you create a custom class which derives from the "Ranorex.WebDocument" adapter?
Maybe this can be handled in another way?
Can you please explain your use case?

Thanks,
Markus

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

Re: inheriting a class give error

Post by Support Team » Mon Oct 21, 2013 1:20 pm

Hello SDimbre,

It seems that you have missed to add two implicit cast operators and a constructor to your class.

Please take a look at class file 'MyAdapter.cs' posted in our forum.
This should give you an idea how to do that:
http://www.ranorex.com/forum/custom-ran ... html#p4855

Regards,
Markus (T)
.
Image