Find element under a form

Ask general questions here.
rajeswari
Posts: 14
Joined: Mon Mar 14, 2016 4:26 pm

Find element under a form

Post by rajeswari » Thu Jun 22, 2017 1:06 pm

Hi,

im trying to find a particular element under a form based on the forminfo(on a windows desktop applicaiton). A similar element is present in 2 forms and based on the input forminfo find the element under that form and click on it.
But the findsingle / find descendant method gives me error, please help.

FormName Rxpath eg:-
Form1 .//form[@controlname~'frmGanttChart']
element1 element[@controlname='atbpRibbon']//element[@controlname='agbGanttChart']
element2 element[@controlname='atbpRibbon']//element[@controlname='agbTileVertical']
element3 element[@controlname='atbpRibbon']//element[@controlname='agbFindBar']

im trying to find the agbFindBar element under different forms based on forminfo.
var AgbFindBar= formInfo.FindAdapter<Form>().FindSingle<Element>("@controlname='agbFindBar'");
var AgbFindBar= formInfo.FindAdapter<Form>().FindDescendant<Element>("agbFindBar");

AgbFindBar.Click();

the reason im

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

Re: Find element under a form

Post by odklizec » Thu Jun 22, 2017 1:11 pm

Hi,

Please upload a Ranorex snapshot (not screenshot) for mentioned element/form and the exact error you are getting! Without snapshot and error message, we can only guess what's the problem.
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

rajeswari
Posts: 14
Joined: Mon Mar 14, 2016 4:26 pm

Re: Find element under a form

Post by rajeswari » Thu Jun 22, 2017 1:19 pm

Error message :-

The type 'Ranorex.Core.Element' cannot be used as type parameter 'T' in the generic type or method 'Ranorex.Adapter.FindDescendant<T>(string)'. There is no implicit reference conversion from 'Ranorex.Core.Element' to 'Ranorex.Adapter'.
Attachments
agbFindBar1.rxsnp
(100.75 KiB) Downloaded 17 times

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Find element under a form

Post by Vaughan.Douglas » Thu Jun 22, 2017 3:54 pm

rajeswari wrote:Error message :-

The type 'Ranorex.Core.Element' cannot be used as type parameter 'T' in the generic type or method 'Ranorex.Adapter.FindDescendant<T>(string)'. There is no implicit reference conversion from 'Ranorex.Core.Element' to 'Ranorex.Adapter'.
If you haven't, it could be helpful to review some background on Ranorex Adapters. The elements are in the Ranorex namespace NOT under Ranorex.Core.

If your app is a Win32 application, you can try NativeItem or NativeWindow. If all else fails you should be able to use Unknown
Doug Vaughan

rajeswari
Posts: 14
Joined: Mon Mar 14, 2016 4:26 pm

Re: Find element under a form

Post by rajeswari » Fri Jun 23, 2017 11:46 am

Hi Vaughan,

Thanks for the suggestion, i'm using Unknown and it works fine. :).

formInfo.FindAdapter<Form>().FindDescendant<Ranorex.Unknown>("agbFindBar").Click();

Thanks
Raj

Vaughan.Douglas
Posts: 250
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Find element under a form

Post by Vaughan.Douglas » Fri Jun 23, 2017 1:54 pm

rajeswari wrote:Hi Vaughan,

Thanks for the suggestion, i'm using Unknown and it works fine. :).

formInfo.FindAdapter<Form>().FindDescendant<Ranorex.Unknown>("agbFindBar").Click();

Thanks
Raj
I am glad to hear that. Just keep in mind "Unknown" is extremely generic, so you may get additional/better functionality if you find a better fit.
Doug Vaughan