Page 1 of 1

Casting from a Ranorex.List class

Posted: Wed Jul 27, 2016 7:17 am
by Raghunath Rajendren
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

Re: Casting from a Ranorex.List class

Posted: Wed Jul 27, 2016 2:19 pm
by krstcs
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.

Re: Casting from a Ranorex.List class

Posted: Fri Jul 29, 2016 1:43 pm
by Raghunath Rajendren
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 ?

Re: Casting from a Ranorex.List class

Posted: Mon Aug 01, 2016 3:11 pm
by Support Team
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

Re: Casting from a Ranorex.List class

Posted: Tue Aug 02, 2016 8:12 am
by Raghunath Rajendren
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

Re: Casting from a Ranorex.List class

Posted: Wed Aug 03, 2016 9:19 am
by Support Team
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
This attribute value could be stored in a module variable or used for validation purposes.
GetValue_DataContext.png
I hope this information will help you.

Sincerely,
Johannes

Re: Casting from a Ranorex.List class

Posted: Fri Aug 12, 2016 7:39 am
by Raghunath Rajendren
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.

Re: Casting from a Ranorex.List class

Posted: Tue Aug 16, 2016 3:36 pm
by Support Team
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

Re: Casting from a Ranorex.List class

Posted: Wed Aug 17, 2016 9:49 am
by Raghunath Rajendren
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.

Re: Casting from a Ranorex.List class

Posted: Wed Aug 17, 2016 1:41 pm
by Support Team
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
I look forward to hearing from you.

Sincerely,
Johannes

Re: Casting from a Ranorex.List class

Posted: Tue Aug 23, 2016 6:16 am
by Raghunath Rajendren
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

Re: Casting from a Ranorex.List class

Posted: Wed Aug 24, 2016 7:21 am
by Support Team
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