findSingle compile error : Automation API

findSingle compile error

Class library usage, coding and language questions.

findSingle compile error

Postby BruceBalen » Wed Jul 01, 2009 11:14 pm

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?
BruceBalen
 
Posts: 9
Joined: Thu Jun 18, 2009 10:57 pm

Re: findSingle compile error

Postby BruceBalen » Wed Jul 01, 2009 11:19 pm

I think I fixed it. I had to change a namespace declaration:

using System.Windows.Forms;
to
using WinForms = System.Windows.Forms;
BruceBalen
 
Posts: 9
Joined: Thu Jun 18, 2009 10:57 pm

Re: findSingle compile error

Postby Ciege » Wed Jul 01, 2009 11:58 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...
User avatar
Ciege
 
Posts: 907
Joined: Thu Oct 16, 2008 7:46 pm
Location: Arizona, USA


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests