Page 1 of 1

AccessibleDefaultAction isn't working

Posted: Wed Jan 19, 2011 3:34 pm
by itmbr
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

Re: AccessibleDefaultAction isn't working

Posted: Wed Jan 19, 2011 9:01 pm
by Support Team
In
tabButtonTree.Element.InvokeAction("strDefaultAction")
you have quote signs around strDefaultAction.
If that's not the reason, please come back.

Regards, Roland

Re: AccessibleDefaultAction isn't working

Posted: Wed Jan 19, 2011 9:59 pm
by Support Team
To invoke the default action you should just do:

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

Regards, Roland

Re: AccessibleDefaultAction isn't working

Posted: Thu Jan 20, 2011 2:58 pm
by itmbr
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

Re: AccessibleDefaultAction isn't working

Posted: Thu Jan 20, 2011 3:27 pm
by Support Team
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

Re: AccessibleDefaultAction isn't working

Posted: Fri Jan 21, 2011 12:38 pm
by itmbr
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

Re: AccessibleDefaultAction isn't working

Posted: Fri Jan 21, 2011 12:51 pm
by Support Team
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