Page 1 of 1

Help getting Accessible Value

Posted: Tue Dec 01, 2009 8:27 pm
by costamesakid
Is there a C# sharp method that will enable me to get the Accessible Value of an object into a variable? Thanks

Re: Help getting Accessible Value

Posted: Wed Dec 02, 2009 5:13 pm
by Support Team
If the element supports the Accessible capability (see following topic in the Ranorex User Guide: http://www.ranorex.com/support/user-gui ... apter.html), then the Accessible.Value property gets you its value:
Accessible accElement = repo.MyApp.MyAccessibleElement;
string accValue = accElement.Value;
Regards,
Alex
Ranorex Support Team

Re: Help getting Accessible Value

Posted: Wed Dec 02, 2009 6:41 pm
by costamesakid
Thanks Alex,

I tried the following code:

Accessible accElement = repo.FormTacViewC2_map_TacVie.CellTrack_Number_0;
string track1 = accElement.Value;

and I got this error message:

Error CS0029: Cannot implicitly convert type 'Ranorex.Cell' to 'Ranorex.Accessible'

Using Ranorex Spy I am fairly certain this element supports Accessibility. I have attached a screen shot of the Cells properties from Ranorex Spy. Thanks
ScreenHunter_03 Dec. 02 11.23.gif

Re: Help getting Accessible Value

Posted: Wed Dec 02, 2009 10:01 pm
by costamesakid
Not sure if this the best way to get the value of an Accessible object but this code worked for me:

Ranorex.Accessible cellTrack0 = "/form[@title~'^TacViewC2\\ \\ \\ \\(map:\\ TacView']/element/container/element/table/cell[@accessiblename='Track Number[0]']";
string track1 = cellTrack0.Value;

Where I create an Accessible object, in this case 'cellTrack0' and set it using the RanoreXPath. Then retrieve the value of that object into a variable.

Re: Help getting Accessible Value

Posted: Thu Dec 03, 2009 5:20 pm
by Support Team
costamesakid wrote:Error CS0029: Cannot implicitly convert type 'Ranorex.Cell' to 'Ranorex.Accessible'
If your repository item is e.g. a Cell and you want to change the adapter type, you need to create a new adapter of the wanted type:
Accessible accElement = new Accessible(repo.FormTacViewC2_map_TacVie.CellTrack_Number_0);
string track1 = accElement.Value;
You can as well use the technique from your last post, but you should use the above code when you use Ranorex repositories.

Regards,
Alex
Ranorex Support Team