Page 1 of 1

findSingle compile error

Posted: Wed Jul 01, 2009 10:14 pm
by BruceBalen
Okay, this one makes absolutely no sense. I'm using a very simple instance of findSingle to locate a save button and click it like this:

Code: Select all

Button save = cmsForm.FindSingle(".//button[@accessiblename='Save']");
I get a compile error:

Cannot implicitly convert type 'Ranorex.Core.Element' to 'System.Windows.Forms.Button' (CS0029)

I've used this plenty of times in other solutions with no trouble. What gives?

Re: findSingle compile error

Posted: Wed Jul 01, 2009 10:19 pm
by BruceBalen
I think I fixed it. I had to change a namespace declaration:

using System.Windows.Forms;
to
using WinForms = System.Windows.Forms;

Re: findSingle compile error

Posted: Wed Jul 01, 2009 10:58 pm
by Ciege
I think the compiler is getting confused as to what Button to use (the System.Windows.Forms.Button or the Ranorex.Button).

Easiest way around this is to change your code (not your using statement) to:

Code: Select all

Ranorex.Button save = cmsForm.FindSingle(".//button[@accessiblename='Save']");
I have actually made it a habit to prefix all Ranorex controls with Ranorex.* just so anyone in the future reading my code will have no ambiguities about what control I am referencing.