AccessibleDefaultAction isn't working

Ranorex Studio, Spy, Recorder, and Driver.
itmbr
Posts: 5
Joined: Mon Oct 11, 2010 9:58 am

AccessibleDefaultAction isn't working

Post by itmbr » Wed Jan 19, 2011 3:34 pm

Hi there,

In the program I have to test I want to Expand (or Collapse) the container, for example "Zentraler Eingriff" with Ranorex.

I've tried to get to it in the program code

Ranorex.Container tabButtonTree = "/adfgdasfg" (the Ranorex-Path)
//Expand the chosen Container
string strDefaultAction = tabButtonTree.Element.GetAttributeValue("AccessibleDefaultAction").ToString();
tabButtonTree.Element.InvokeAction("strDefaultAction");

but, I don't know why, the access to the AccessibleDefaultAction (which would be "Expand" if the container is closed and in the other way if it is opened) is denied.

So I built a workaround with an easy Click()-Event instead of the code I told before, but it isn't really satisfying.

Maybe you know another possibility to solve this problem? Or is this the only way to Expand/Collapse a Container?

Best Regards
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: AccessibleDefaultAction isn't working

Post by Support Team » Wed Jan 19, 2011 9:01 pm

In
tabButtonTree.Element.InvokeAction("strDefaultAction")
you have quote signs around strDefaultAction.
If that's not the reason, please come back.

Regards, Roland

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: AccessibleDefaultAction isn't working

Post by Support Team » Wed Jan 19, 2011 9:59 pm

To invoke the default action you should just do:

Accessible acc = tabButtonTree.Element;
acc.DoDefaultAction();

Regards, Roland

itmbr
Posts: 5
Joined: Mon Oct 11, 2010 9:58 am

Re: AccessibleDefaultAction isn't working

Post by itmbr » Thu Jan 20, 2011 2:58 pm

Hi,

thank you for your answer. I tried your last suggestion in my Code, but at first i could not find an Object called 'Accessible', only 'AccessibleObject'. With that I got the error

'Cannot implicitly convert type 'Ranorex.Core.Element' to 'System.Windows.Forms.AccessibleObject'.

So, where can I find the 'Accessible'-Object?

Best Regards

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: AccessibleDefaultAction isn't working

Post by Support Team » Thu Jan 20, 2011 3:27 pm

itmbr wrote:I tried your last suggestion in my Code, but at first i could not find an Object called 'Accessible', only 'AccessibleObject'. With that I got the error
If you do not have a "using Ranorex;" statement at the beginning of your code file, you have to specify the full name "Ranorex.Accessible" for that class. The "using" statement should be there if you use the Ranorex Studio code templates.

Regards,
Alex
Ranorex Team

itmbr
Posts: 5
Joined: Mon Oct 11, 2010 9:58 am

Re: AccessibleDefaultAction isn't working

Post by itmbr » Fri Jan 21, 2011 12:38 pm

Although I have an "using Ranorex;"-statement in my Code, I have no "Ranorex.Accessible".

So, I get with tabButtonTree.MoveTo() close to the container. So I want to get with the mouse exactly to the container. I saw there is an "Mouse.Position.X"-property, but if i do the command

Mouse.Position.X += 5;

i get an error "Cannot modify the return value of 'Ranorex.Mouse.Position' because it is not a variable". Of course, it's an object, but i have to get on this X and Y-values. Do you have an idea?

Thanks for the answers and regards

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: AccessibleDefaultAction isn't working

Post by Support Team » Fri Jan 21, 2011 12:51 pm

itmbr wrote:Although I have an "using Ranorex;"-statement in my Code, I have no "Ranorex.Accessible".
It looks like you did not use the default Ranorex template for creating your project. You have to add references to all Ranorex plugin to your project. See following section in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... rence.html
itmbr wrote:Mouse.Position.X += 5;
The correct syntax is the following:
Mouse.Position += new Size(0, 5);
However, it is much easier to specify a relative location in the MoveTo method, e.g.:
tabButtonTree.MoveTo("15;20")
Regards,
Alex
Ranorex Team