Page 1 of 1

Cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Posted: Wed Sep 26, 2018 10:10 am
by mohan.pentyala
Hi

I have created a function to perform click operation on buttons.I am trying to call that fuction by passing object from reporsitoy .But it is giving me error as cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Can you please help me to resolve the issue :

Funcation :

public bool fn_IsButtonVisibleEnabled(Button Objfusion)
// {
// Boolean visible = Objfusion.Element.Visible;
// Boolean enabled = Objfusion.Element.Enabled;
// if(visible == true && enabled == true)
// return true;
// else
// return false;
// }
#endregion


Locator from Repository :

/form[@title='Fusion']//element[@windowtext='Save']


Code module :
loc.fn_ClickButton(repo.Fusion.btnSave);

Re: Cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Posted: Wed Sep 26, 2018 10:59 am
by odklizec
Hi,

The element in question is apparently not a button, so why do you need to convert it to button? BTW, the click operation should be possible even on unknown element. So why do you need to convert it to button anyway? ;)

Re: Cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Posted: Wed Sep 26, 2018 12:43 pm
by mohan.pentyala
I want to use the function as common function across my framework and pass the locator object at run time . So What can i define in the function ?


odklizec wrote:
Wed Sep 26, 2018 10:59 am
Hi,

The element in question is apparently not a button, so why do you need to convert it to button? BTW, the click operation should be possible even on unknown element. So why do you need to convert it to button anyway? ;)

Re: Cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Posted: Wed Sep 26, 2018 12:50 pm
by odklizec
So keep it unknown? If I'm not mistaken, attributes like 'visible' and 'click' method should be available even for unknown elements?

Re: Cannot convert from 'Ranorex.Unknown' to 'Ranorex.Button'

Posted: Wed Sep 26, 2018 1:07 pm
by mohan.pentyala
Yes ,It is working

Thanks for the help :)