Help getting Accessible Value

Ask general questions here.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Help getting Accessible Value

Post by costamesakid » Tue Dec 01, 2009 8:27 pm

Is there a C# sharp method that will enable me to get the Accessible Value of an object into a variable? Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Help getting Accessible Value

Post by Support Team » Wed Dec 02, 2009 5:13 pm

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
.
Image

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Help getting Accessible Value

Post by costamesakid » Wed Dec 02, 2009 6:41 pm

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

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Help getting Accessible Value

Post by costamesakid » Wed Dec 02, 2009 10:01 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Help getting Accessible Value

Post by Support Team » Thu Dec 03, 2009 5:20 pm

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
.
Image