Casting from a Ranorex.List class

Ask general questions here.
Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Casting from a Ranorex.List class

Post by Raghunath Rajendren » Wed Jul 27, 2016 7:17 am

Hi,

I am working on to automate a WPF-based desktop application using Ranorex. Some WPF controls like ItemsControl are Tracked as Ranorex.List in the WPFOnly (WPF Legacy/UIA Interaction Setting in the Settings wizard). My requirement requires a cast of that List class into its actual WPF control class. When I add the WPF references and try a direct cast, Ranorex throws a compile-time error. Is there a way we can do it ?

PS: Ranorex v6.0

Thanks,
Raghu

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Casting from a Ranorex.List class

Post by krstcs » Wed Jul 27, 2016 2:19 pm

Please upload a Ranorex Snapshot (NOT a screenshot!) of the item. Without that it will be almost impossible to know what is going on.


In general, I would say that you shouldn't be casting any elements to different types. If Ranorex sees the item as a Ranorex.List, then that is what Ranorex needs to use to be able to identify and operate on the element. You have to work with what Ranorex gives you. Don't try to make it something else just because the names don't match what you might think it should be. If Ranorex says it's a Ranorex.List, then leave it as that because it's probably the best match for the element that Ranorex has.

But, again, without a Ranorex Snapshot of the element, it's impossible for us to know for sure.
Shortcuts usually aren't...

Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Re: Casting from a Ranorex.List class

Post by Raghunath Rajendren » Fri Jul 29, 2016 1:43 pm

Please find attached the snapshots of a wpf 'ItemsControl' in UIA and WPF settings.

We need this item to be detected as an ItemsControl element. If it is possible, what should we be doing in Ranorex to get the type and element detected correctly ?
Attachments
ItemsControl_WPFOnly_Snapshot.rxsnp
ItemsControl detected as List in WPF option
(603.9 KiB) Downloaded 46 times
ItemsControl_UiaOnly_Snapshot.rxsnp
ItemsControl detected as Container in UIA option
(141.84 KiB) Downloaded 32 times

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

Re: Casting from a Ranorex.List class

Post by Support Team » Mon Aug 01, 2016 3:11 pm

Hi Raghu,

I'm afraid to tell you that there is no way to cast this Adapter to the base type of the WPF element.
May I ask what exactly you want to accomplish? Probably, we could help you finding a different way to implement your use case.

I look forward to hearing from you.

Sincerely,
Johannes
.
Image

Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Re: Casting from a Ranorex.List class

Post by Raghunath Rajendren » Tue Aug 02, 2016 8:12 am

In our test case, we want to access the DataContext of the UIelement, to further work on from the values in it. For that, we need a proper casting/boxing to the exact type of Control to get access of DataContext.

FYI, 3rd party utility tools (attaches to a running WPF application to troubleshoot common problems with layouting, databinding or styling) like Snoop and WPF Inspector are identifying the Control elements as such and we are view the DataContext. See attachment for how we access the DataContext (it is not the same control used for detection in my previous attachments).

Is there a way to do it in similar manner ?

Thanks in advance,
Raghu
Attachments
Capture1.PNG
Capture1.PNG (126.66 KiB) Viewed 1061 times

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

Re: Casting from a Ranorex.List class

Post by Support Team » Wed Aug 03, 2016 9:19 am

Hi Raghu,

According to the attached snapshot, the DataContext attribute seems to be available for the corresponding UI element and for other elements, too.
Ranorex_Spy_DataContext.rxsnp.png
Ranorex_Spy_DataContext.rxsnp.png (40 KiB) Viewed 1051 times
This attribute value could be stored in a module variable or used for validation purposes.
GetValue_DataContext.png
GetValue_DataContext.png (2.65 KiB) Viewed 1051 times
I hope this information will help you.

Sincerely,
Johannes
.
Image

Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Re: Casting from a Ranorex.List class

Post by Raghunath Rajendren » Fri Aug 12, 2016 7:39 am

Hi,

I tried to use GetValue on the Docking element as mentioned. But the return type is of a string stating "ByRef<MainWindowViewModel>{38159654, Amtech.ProDesign.Framework.ViewModels.MainWindowViewModel}".
Using that, how should I be deserializing the class data?. Because the DataContext which we used for binding the Docking element is a class.

Also, what you have shown is using the WPF snapshot, only where the DataContext value is available and not in the UIAutomation setting.
And in our application, the Docking is a top level entity and there are several Child entities present.
1. in UIA: 'Track' on a child entity is recognized as 'Ranorex.Unknown'("SupplyView"). Now on this element, DataContext is not available.
2. in WPF : 'Track' on the same child entity still returns only as Docking (parent). Expanding the "List(Docking) does not contain that child element as well.
Moving forward, we will have to get DataContext on almost of the elements (some of which are accessible in UIA and some in WPF).

Please refer to the attached WPF and UIA based element Snapshots. They were 'Tracked' while clicking on the same element.

I know there are many questions, but I would really appreciate your valuable answers. And sorry for the late reply on the post.
Attachments
DataContextItem_WPFSnapshot.rxsnp
(580.73 KiB) Downloaded 42 times
DataContextItem_UIASnapshot.rxsnp
(114.06 KiB) Downloaded 30 times

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

Re: Casting from a Ranorex.List class

Post by Support Team » Tue Aug 16, 2016 3:36 pm

Hi Raghu,

I forwarded this query to the responsible developer. I will get back to you regarding whether there is a way to read the DataContext property and process this information properly.

I'm afraid to tell you that there won't be a way to read the DataContext property via the UIA plugin. The UI Automation interface doesn't provide the corresponding property. In this case, you will need to use the native WPF plugin for object recognition.

I will update this thread as soon as possible.

Sincerely,
Johannes
.
Image

Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Re: Casting from a Ranorex.List class

Post by Raghunath Rajendren » Wed Aug 17, 2016 9:49 am

Hi,

Thanks for the reply. Yeah, the concept of DataContext applies only to WPF recognition mode. But, the children elements are not getting detected in WPF, on which we want the DataContext value too. Anyway, I will wait for the reply from your developer team.

Thanks very much for the response.

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

Re: Casting from a Ranorex.List class

Post by Support Team » Wed Aug 17, 2016 1:41 pm

Hi Raghu,

Accessing those properties requires additional implementation in the application under test. Furthermore, you will need to use internal Ranorex API that is not documented. If you want, I could send you a sample project that demonstrates how to access those properties. Please send an email to [email protected] in order I can send you the sample project.

If the children elements are not recognized with the native WPF plugin, this issue could probably be resolved by modifying the WPF plugin configuration.

In order to analyze the issue, I would need the following information.
show_all_elements.png
show_all_elements.png (16.86 KiB) Viewed 993 times
I look forward to hearing from you.

Sincerely,
Johannes
.
Image

Raghunath Rajendren
Posts: 7
Joined: Fri Apr 01, 2016 8:34 am

Re: Casting from a Ranorex.List class

Post by Raghunath Rajendren » Tue Aug 23, 2016 6:16 am

Hi Johannes,

I modified the option 'Show All Elements' to True and was able to identify the child element, but it is as Ranorex.Element and is not detected on using 'Highlight element'. With that said, I received a sample project including the internal Ranorex API support. I am yet to investigate it. Will let you know once I am done with that.

I am unable to attach the new Ranorex Snapshot, as the file size exceeds 1MB. Shall I mail the attachment? If so, please specify the mail id.

Thanks,
Raghu
Attachments
Child Element with Show all Elements Option FALSE.rxsnp
(916.32 KiB) Downloaded 36 times

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

Re: Casting from a Ranorex.List class

Post by Support Team » Wed Aug 24, 2016 7:21 am

Hello Raghu,

As mentioned in my last email, please send a new support query including both Ranorex Snapshots to [email protected].

After we received this information, we will analyze the issue.

Sincerely,
Johannes
.
Image