Using "Select" method in a text box

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Using "Select" method in a text box

Post by daa » Tue Feb 01, 2011 1:24 pm

We have a Delphi application with what appear to be standard text boxes. Using Spy identifies them as Ranorex.Text (i.e. RxPath ends in "/text"), and a rummage about in the "Capabilities/Actions" part of Spy shows support for the "Select" action.

However, when I call the Select(int1, int2) method of the object, I get

System.NotSupportedException: The operation is not supported.
at Ranorex.Plugin.MsaaFlavorElement.InvokeAction(Element element, String name, Object[] args)

Is there ank known problems with setting the select area on Delphi applications?
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Using "Select" method in a text box

Post by Support Team » Tue Feb 01, 2011 4:17 pm

Hi,

unfortunately it's not possible to invoke the .Select methods of MSAA elements, becaus it is simply not supported by MSAA.
But you can check if there is a Win32 control which also holds the text underlying the MSAA element.
If so, you can you the .Select method of this control.

If this won't work you can use a "Key Sequence Item" or a "Mouse Item" to perform a selection on the text.

Regards,
Tobias
Support Team

User avatar
daa
Posts: 22
Joined: Tue May 19, 2009 2:01 pm
Location: York, UK
Contact:

Re: Using "Select" method in a text box

Post by daa » Tue Feb 01, 2011 4:20 pm

OK, right... I've programmed round this in a different way now, but it seems odd that Spy reports the capability as being present when it isn't.

Anyway, one to remember for the future.
David Allsopp,
Test Automation Engineer, Mitrefinch Ltd.

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

Re: Using "Select" method in a text box

Post by Support Team » Tue Feb 01, 2011 11:27 pm

daa wrote:but it seems odd that Spy reports the capability as being present when it isn't
Even if an element supports a capability, some attributes/actions might not work, e.g. simply because the control does not support that functionality and there is usually no way of knowing that a priori.

We try to assign the role that best fits the element. If MSAA is the underlying technology that can sometimes be a bit tricky, because MSAA is a rather old and quite limited interface. In addition, many control vendors do not care to implement MSAA completely and often lack some functionality.

Consequently, it is usually control specific which attributes/actions are really supported and you need to test that out. As a fallback you can use mouse and keyboard actions - those will work with every element :)

Regards,
Alex
Ranorex Team
.
Image

Zhilll
Posts: 13
Joined: Thu Oct 06, 2011 2:48 pm

Re: Using "Select" method in a text box

Post by Zhilll » Fri Sep 14, 2012 7:17 pm

Does this also apply to FlexFlavorElements? I'm trying to use the Select method on a textDisplay, but am getting the same error message:

Ranorex.ActionFailedException: Action 'select' failed on element '{Text:textDisplay}'. ---> System.NotSupportedException: The operation is not supported.
at Ranorex.Plugin.FlexFlavorElement.InvokeAction(Element element, String name, Object[] args)
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
--- End of inner exception stack trace ---
at Ranorex.Core.Element.InvokeAction(String name, Object[] args)
at Ranorex.Text.Select(Int32 start, Int32 length)
at J2012RegressionTests.Tests.HeadnoteTest.BasicWordphraseTest() in c:\Users\U0213010\Documents\J2012SummaryRegression\J2012RegressionTests\Tests\HeadnoteTest.cs:line 118

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

Re: Using "Select" method in a text box

Post by Support Team » Tue Sep 18, 2012 9:52 am

Hello,

Which flex class is used for the 'textDisplay' element?
'textDisplay' is only the name of the element. Please give us more information about your issue.

Regards,
Bernhard
Ranorex Support Team
.
Image

JohnWashburn
Posts: 54
Joined: Wed Jan 09, 2013 7:02 pm

Re: Using "Select" method in a text box

Post by JohnWashburn » Wed Apr 17, 2013 10:48 pm

In our application the underlying accessibility technology for our winform application is UI Automation , but the Ranorex runtime DLLs
(Ranorex.Core.dll, Ranorex.Libs.WinForms.dll, Ranorex.Plugin.Msaa.dll, Ranorex.Plugin.Web.dll, Ranorex.Plugin.Win32.dll, Ranorex.Plugin.WinForms.dll, Ranorex.Plugin.Wpf.dll,etc.)

insist on treating these controls with UIA interfaces as if they have use MSAA as the accessibility technology.

if
...MSAA is a rather old and quite limited interface. In addition, many control vendors do not care to implement MSAA completely and often lack some functionality.
is true then why limit winform applications to this "rather old and quite limited interface" when the controls used in the Winform application support UIA?

Is there a environment switch or registry entry I can set so Ranorex DLL's will treat winform applications as having UI Automation?

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

Re: Using "Select" method in a text box

Post by Support Team » Thu Apr 18, 2013 8:39 am

JohnWashburn wrote:In our application the underlying accessibility technology for our winform application is UI Automation , but the Ranorex ... insist on treating these controls with UIA interfaces as if they have use MSAA as the accessibility technology.
This is correct. As I posted before, UIA is kind of a replacement for MSAA. Because of that, Microsoft added a bridge between those two technologies, mapping MSAA to UIA properties and vice versa. So if you implement either MSAA or UIA in your control, you actually automatically support both technologies.

The problem for Ranorex now is that we cannot tell from the outside if the control either natively supports MSAA or UIA, because it responds to both technologies thanks to that bridge. As WinForms natively only supports MSAA, Ranorex uses the MSAA interface for WinForms controls (whereas UIA is used for WPF controls).
JohnWashburn wrote:Is there a environment switch or registry entry I can set so Ranorex DLL's will treat winform applications as having UI Automation?
No, there isn't, simply because for WinForms controls there is an even better alternative than using UIA: Instead of working with the MSAA element corresponding to the control in Ranorex, work with the "Control" element (usually the parent of the MSAA element). Both elements correspond to the same WinForms control, but provide very different attributes.
The Control element will show you all properties of the WinForms control, allows you to invoke method and even code inside the WinForms control. This is usually much more functionality than what UIA would provide for the control.

Regards,
Alex
Ranorex Team
.
Image

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

Re: Using "Select" method in a text box

Post by Support Team » Fri Apr 26, 2013 8:53 am

I have a (positive) update on this issue :D
We had our developers get into that problem again and it seems we have found a way to distinguish whether a window/control natively implements UIA or MSAA. The check works reliably for all of our test applications, but we cannot be 100% sure it works for your controls without having a sample app.
Would you be willing to create a sample app containing a few of your WinForms controls implementing UIA and send it to Ranorex support?

With the next minor version (V4.1.0) the WPF plugin will have a setting to turn on element generation for windows/controls that natively implement UIA. The generated elements will be created in addition to the existing MSAA elements, so existing RanoreXPaths should still work. However, if the setting is switched on, Spy will use the new UIA elements when tracking.

Regards,
Alex
Ranorex Team
.
Image

JohnWashburn
Posts: 54
Joined: Wed Jan 09, 2013 7:02 pm

Re: Using "Select" method in a text box

Post by JohnWashburn » Tue Apr 30, 2013 12:52 am

I posted a sample app as a response for:
http://www.ranorex.com/forum/list-adapt ... t4565.html

JohnWashburn
Posts: 54
Joined: Wed Jan 09, 2013 7:02 pm

Re: Using "Select" method in a text box

Post by JohnWashburn » Tue Apr 30, 2013 12:57 am

This is excellent news. any ETA on the Beta for 4.1?

I am willing to be your guinea pig on this as it relates to Telerik controls in a Winform App.

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

Re: Using "Select" method in a text box

Post by Support Team » Tue Apr 30, 2013 12:56 pm

I analyzed the sample app you posted with some interesting results: Unlike alleged in this forum topic, Telerik does NOT implement UI Automation (UIA) for their WinForms controls in that sample app, in particular not for the RadListControl. All they do is provide standard MSAA support as WinForms controls usually do.
(I'm pretty sure of this statement after checking with various tools (UI Spy, UIAVerify, Ranorex) and even inspecting the code using Reflector.)

Consequently, Ranorex 4.1.0 will not change anything for these controls.

Back to the original problem: The "Select" action is not supported for MSAA elements with role "Text". Sadly, that's a limitation of the underlying technology we cannot do anything against. However, with WinForms controls - as stated in my original answer - the alternative is to not use the MSAA element, but the parent WinForms element that does support that attribute (and a lot of other attributes in addition).

In your sample, that is the element with control name "radListControl1" (the parent element of the corresponding MSAA element). You can set the "SelectedItemIndex" there without a problem.

Regards,
Alex
Ranorex Team
.
Image

JohnWashburn
Posts: 54
Joined: Wed Jan 09, 2013 7:02 pm

Re: Using "Select" method in a text box

Post by JohnWashburn » Tue Apr 30, 2013 8:33 pm

Are you sure that you cna select the index on the radListControl1?

I changed the line in the driver application (RanorexThread4565.exe) to:

Code: Select all

RxObjectPath_ListBox = "/form[@controlname='TelerickWhetstone']/container[@controlname='radDock1']/container[@controlname='toolTabStrip4']/container[@controlname='toolWindow3']/container/container[@controlname='splitPanel1']/container/list[@accessiblename='radListControl1']";
as suggested in the post above and you get the same exception:
Setting attribute 'selecteditemindex' failed on element '{List:radListControl1}'.
when I executed the lines:

Code: Select all

var listBoxFound = Ranorex.Host.Local.FindSingle<Ranorex.List>(RxObjectPath_ListBox, DefaultSearchTimeout);
listBoxFound.SelectedItemIndex = 0;
The list box control is found and is List-ish enough for the Adaptor but not enough to set the index of the selected item.

If I change the object path to the control one up in the hierarchy with:

Code: Select all

RxObjectPath_ListBox = "/form[@controlname='TelerickWhetstone']/container/container/container/container/container/container[@controlname='radListControl1']";
then you get the sensible exception:
The element does not support the required capability 'list'.

JohnWashburn
Posts: 54
Joined: Wed Jan 09, 2013 7:02 pm

Re: Using "Select" method in a text box

Post by JohnWashburn » Tue Apr 30, 2013 8:54 pm

I am still open to be a beta tester for Ranorex 4.1.0.

Our Devleoper states that if Telerik is supporting enough of the UI Automation, then it should be possible to create custom (i.e Cognex created) interfaces that can be added to the UI Automation class exposed by Telerik.

The hope is these interface "shims" are enough bridge the gap and make the Telerik partial UI Automation appear complete enough to runtime in Ranorex.Core.DLL.

We are keen to try this approach if possible.

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

Re: Using "Select" method in a text box

Post by Support Team » Wed May 01, 2013 11:30 am

Support Team wrote:Are you sure that you cna select the index on the radListControl1?
Yes, I am. You can try it yourself. Open the app, open Ranorex Spy, track a list item. In the element tree in Spy, right-click the list item, click on the "Select" method at the very bottom in the context menu.

Alternatively, select the list "container[@controlname='radListControl1']" (this is the parent element of the list element with accessiblename='radListControl1') in the element tree, open the "Details" tab, scroll down to the "Dynamic" attributes, scroll further down to "SelectedItemIndex" and set the index of the item you want to be selected.
JohnWashburn wrote:as suggested in the post above and you get the same exception:
In my last post I wrote that you need to use the "container[@controlname='radListControl1']" element, not the list element (which uses MSAA as the underlying technology), like explained above.
As this element is not directly recognized as a list, you cannot use the Ranorex."List" adapter (that's why you get that sensible exception; you might want to read this section in the Ranorex User Guide). However, the "SelectedItemIndex" is provided as a dynamic attribute (a custom attribute/property of that control). So there is no adapter property available for that attribute (and no code auto-completion), you have to use the Element.SetAttributeValue method instead.
If you are not familiar with this method, I recommend using the recorder: Add a "Set Value" action, choose the radListControl1 element from your repository, and then select the "SelectedItemIndex" attribute in the "Name" drop-down of the action. You can then also view the code the recorder generates.
JohnWashburn wrote:Our Devleoper states that if Telerik is supporting enough of the UI Automation, then it should be possible to create custom (i.e Cognex created) interfaces that can be added to the UI Automation class exposed by Telerik.
There is no UI Automation implementation present in the controls of the sample app you provided, just MSAA. So the new feature would not be available. And you cannot define your own interfaces, neither with MSAA nor UI Automation; you can only use existing ones.

Anyway, the functionality you need is already there (even more then you will probably need). When using the Ranorex.Control adapter (on the "container[@controlname='radListControl1']", which is a WinForms control), you can get/set all properties of the control and even let arbitrary code be executed directly on the control.(although this should not be needed; see this blog for more info).

Regards,
Alex
Ranorex Team
.
Image