Hello,
I have created wrapper of Ranorex.WebElement something like below.
namespace WObject
{
public class WWebElement : Ranorex.WebElement
{
public WWebElement()
: base()
{
}
public WWebElement(Element element)
: base(element)
{
}
public static implicit operator WWebElement(string path)
{
return new WWebElement(path);
}
public static implicit operator WWebElement(Ranorex.Core.Element element)
{
return new WWebElement(element);
}
}
}
When I am using this wrapper like below
WObject.WWebElement controlToEdit = ele.As<WObject.WWebElement>().NextSibling;
it says Cannot implicitly convert type 'Ranorex.WebElement' to 'WObject.WWebElement'. An explicit conversion exists (are you missing a cast?)
Looks like "ele.As<WObject.WWebElement>().NextSibling" is returning parent element (whereas I think it should return child.)
What is the problem here? Why not child 'WObject.WWebElement' has inherited property '.NextSibling'?
Thanks in advance...
child class is not inheriting property from parent
Re: child class is not inheriting property from parent
Any suggestion on this.
I have tried redefining in child like "new public WWebElement NextSibling { get; set; }"
but this returns null object and not next element.
WObject.WWebElement controlToEdit = ele.As<WObject.WWebElement>().NextSibling;
//controlToEdit is null when tried redefining NextSibling in child class.
Also I should not need to Redefine this way in child class or should I ? What's the use of inheritance then?
Thanks in advance...
I have tried redefining in child like "new public WWebElement NextSibling { get; set; }"
but this returns null object and not next element.
WObject.WWebElement controlToEdit = ele.As<WObject.WWebElement>().NextSibling;
//controlToEdit is null when tried redefining NextSibling in child class.
Also I should not need to Redefine this way in child class or should I ? What's the use of inheritance then?
Thanks in advance...
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: child class is not inheriting property from parent
The NextSibling is indeed inherited (otherwise you could not call itrkarhe wrote:What is the problem here? Why not child 'WObject.WWebElement' has inherited property '.NextSibling'?

WObject.WWebElement controlToEdit = ele.As<WObject.WWebElement>().NextSibling.As<WObject.WWebElement>();
In C#, what you did is not a "redefine", but a new property that is just named "NextSibling" and that hides the base property. Consequently, this new property will just stay "null" forever (unless you assign the property to some value).rkarhe wrote: have tried redefining in child like "new public WWebElement NextSibling { get; set; }"
Regards,
Alex
Ranorex Team