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

Ask general questions here.
mohan.pentyala
Posts: 14
Joined: Thu Sep 20, 2018 7:43 am

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

Post by mohan.pentyala » Wed Sep 26, 2018 10:10 am

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);

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » 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? ;)
Pavel Kudrys
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

mohan.pentyala
Posts: 14
Joined: Thu Sep 20, 2018 7:43 am

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

Post by mohan.pentyala » Wed Sep 26, 2018 12:43 pm

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? ;)

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Wed Sep 26, 2018 12:50 pm

So keep it unknown? If I'm not mistaken, attributes like 'visible' and 'click' method should be available even for unknown elements?
Pavel Kudrys
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

mohan.pentyala
Posts: 14
Joined: Thu Sep 20, 2018 7:43 am

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

Post by mohan.pentyala » Wed Sep 26, 2018 1:07 pm

Yes ,It is working

Thanks for the help :)