How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by benny28 » Thu Apr 09, 2015 4:58 pm

Hello,

Setup: Ranorex 5.3 with Visual Studio as our IDE (with Ranorex repositories).

I need to specify the new Plugin 'WPF Legacy/UIA Interaction' = UiaPreferred. I had assumed that updating the setting in Spy Plugins, then saving the repository, that the setting would filter through to the project in Visual Studio. But this does not work, it's still the default setting of WpfPreferred.

Is there code that I can use to force this setting of 'WPF Legacy/UIA Interaction' = UiaPreferred ?
Or how can I get the setting to filter through to our Visual Studio project?

Cheers

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Fri Apr 10, 2015 3:11 pm

Hello Benny,

In order to set the WPF Legacy / UIA Interaction settings in code you can use the following:
Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.<UiaOnly/UiaPreferred/WpfOnly/WpfPreferred>;
I also did a small test with the setting of the plugins tab, but in my case this worked, so the setting used was also applied to the tests executed from Visual Studio.
May I therefore ask you to upgrade to Ranorex 5.3.1 and to check if it works with this version?

Regards,
Markus

benny28
Posts: 34
Joined: Thu May 31, 2012 4:48 pm
Location: London
Contact:

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by benny28 » Tue Apr 14, 2015 10:12 am

Thanks Markus, the direct code in VS worked.

I've now upgraded to 5.3.1 and it seems to be working correctly now.

Am I correct in saying that there is no way to tell from either the .Repository.cs or .rxrep files, how this pluin is set?

Can different Repositories have this setting set differently, or is the setting specific to the whole project?

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Thu Apr 16, 2015 2:07 pm

Hi Benny,

Yes, it is not possible from the repository to tell how the plugin is set.

The setting is a general setting, so applies to all projects of your machine.
To be sure that the new settings are properly saved you should use the following code:
Configuration.Current.SaveToUserSettings();
Why do you want it repository specific?
Your old UIA tests/repository items should still work when you use WpfPreferred and the new WPF tests/repository items should also run with the setting UiaPreferred, respectively, so there shouldn't be a need to change that on a repository basis.
Please do let me know if I got something wrong here.

Regards,
Markus

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by krstcs » Thu Apr 16, 2015 3:41 pm

I think the issue is that if the UiaPrefered setting works with the SUT, it works everywhere, but if it doesn't work with the SUT, it won't work anywhere, so it would be better to have the setting saved with the solution/project instead of on the user's system.

I would agree with Benny on this one. Some of the settings that are machine specific, currently, might be better as solution or project settings because they may need to be distributed to all Ranorex installs with the solutions.

Note: I don't have this problem right now, so I couldn't point out any specific settings.

But, it's just my 2 cents...
Shortcuts usually aren't...

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Fri Apr 17, 2015 4:39 pm

Hi krstcs,

Thank you for your valuable input kelly.

In case of the specific WPF setting I would agree.
Beside this setting, which other settings do you think are better to have project specific?

Regards,
Markus

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by krstcs » Fri Apr 17, 2015 8:41 pm

I use the default settings for my projects, I haven't found any need to change them yet. (And that also means that I may not realize that some of these are already in the solution... :D)

I could see things like the following being in a solution config file instead of machine local:
GDI Capture settings
XPath weights and capture mode (this may need to change depending on the project)
Use asynchronous dispatching of mouse and keyboard events (again may need changes in each solution)

But, these are examples. I just think that anything that might depend on the SUT should probably be in a solution-level config file instead of in a machine-level file. It just makes more sense to me to keep those things together. It would also make sharing those configurations easier by allowing them to be put under version control with the source.
Shortcuts usually aren't...

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Tue Apr 21, 2015 3:26 pm

Hi Kelly,

You are right, this would make definitely sense.
I will forward this request.

Thanks,
Markus

manishrn91
Posts: 16
Joined: Wed Aug 17, 2016 9:26 am

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by manishrn91 » Mon Nov 14, 2016 1:18 pm

Hi All

I am using Ranorex 6.0.1. while automating my desktop application In Global setting I have kept 'WPF Legacy/UIA Interaction' = UiaPreferred and captured controls,

However in some of the Ranorex couldn't find some of the WPF controls,So I changed WPF Legacy/UIA Interaction' = WpfPreferred and then Ranorex was able to find those controls.

While running the test case by default value of WPF Legacy/UIA Interaction' = UiaPreferred , Whenever I needed I changed it to WpfPreferred using usercode ( Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.WpfPreferred;)
and changing it back to Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.UiaPreferred;

Sometimes this works and sometimes it doesn't.

Could you please suggest me if any other way is possible ?

Let me know if you want some more clarity on this.

Regards,
Manish

manishrn91
Posts: 16
Joined: Wed Aug 17, 2016 9:26 am

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by manishrn91 » Tue Nov 15, 2016 4:38 pm

Hi Support Team,


Any updates on this ?


Regards
Manish

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Wed Nov 16, 2016 2:30 pm

Hello Manish,

May I ask what exactly happens? Which error message do you get?

Also, we highly recommend sticking to one plugin, either UIA or WPF. Please try to limit the switching between those plugins.

Looking forward to hearing from you.

Sincerely,
Robert

manishrn91
Posts: 16
Joined: Wed Aug 17, 2016 9:26 am

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by manishrn91 » Wed Nov 16, 2016 3:00 pm

Hi Robert,

It doesnt give any error message.

I have captured object by keeping 'WPF Legacy/UIA Interaction' = UiaPreferred. setting.
Object Identification of some of the wpf element is not possible in application which I am trying to automate.
So when I change setting to WPF Legacy/UIA Interaction' = WpfPreferred it identifies object.

whenever I am dealing with those wpf elements which are not recognized using UiaPreffered setting, by using usercode I am changing the WPF Legacy/UIA Interaction settings as mentioned in above question.
sometimes it works and sometimes it doesn't .

Do we have some other way to change this setting ?

I am not using WPF Legacy/UIA Interaction' = WpfPreferred setting through out because xpath becomes very long.




Regards,
Manish

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

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by Support Team » Thu Nov 17, 2016 1:09 pm

Hello Manish,

Thank you for getting back to me.

Unfortunately, I'm not sure why it is even necessary to switch between WpfPreferred and UIAPreferred. All paths should be found during test execution.

If you still want to switch, please try to save the configuration right after performing the switch:

Code: Select all

Configuration.Current.SaveToUserSettings();  
There is no other code for switching the WPF settings.

Sincerely,
Robert

manishrn91
Posts: 16
Joined: Wed Aug 17, 2016 9:26 am

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by manishrn91 » Sat Nov 19, 2016 10:05 pm

Hi Robert

Yes, During test execution I can find the all the path now, but its taking some more time.
I will try the solution you have given.

Thank you



Regards,
Manish

EugeneMkv
Posts: 29
Joined: Thu Nov 30, 2017 3:52 pm

Re: How to set plugin 'WPF/UIA' = UiaPreferred in VS code?

Post by EugeneMkv » Thu Jan 18, 2018 1:49 pm

Support Team wrote: All paths should be found during test execution.
Doesn't work this way. Version 7.2.1 is not able to find components using UIA paths if current mode was set to WpfImrovedOnly and vice versa.
At least in my case (WPF, Telerik).

For example UIA-based path:

Code: Select all

/form[@processname='app.Shell']/progressbar/element[@classname='RadTransitionControl']/element[@classname='CommonView']/element[@automationid='Docking']/element[@classname='RadSplitContainer']/tabpagelist/tabpage[@automationid='SubModulesPane']/progressbar/tabpagelist/tabpage[@name='Information']
Ranorex won't find it with WpfImrovedOnly set globally.

The same control based on WpfImrovedOnly:

Code: Select all

/form[@processname='app.Shell'']/progressbar/list[@automationid='Docking']/container[@automationid='Root']/?/?/tabpage[@automationid='SubModulesPane']//container[@automationid='HeaderDockedElement']/tabpage[@title='Information']
Ranorex won't find it with UIAonly set globally.

Code: Select all

Configuration.Current.SaveToUserSettings();  
Doesn't help.
At least this combination doesn't work for me:

Code: Select all

private void Init()
        {
        	Report.Info("Setting WpfTreeSelection.UiaOnly");
        	Ranorex.Plugin.WpfConfiguration.WpfApplicationTrees = Ranorex.Plugin.WpfTreeSelection.UiaOnly;
        	Configuration.Current.SaveToUserSettings();
            
        }
And one more important thing I'd like to notice.
In some cases WpfImrovedOnly mode causes a SUT (WPF+Telerik) to hang (with RAM leakage).
It happens exactly after Ranorex inject its dlls (Ranorex.Core.Injection.dll) into SUT process.
And it happens in case when the SUT is x64-based application (unfortunately we have no x86 version and I can't check this) and a 32/64 bit Bridge is used.
I've just checked this scenario using TestComplete - no problem, SUT works fine...

ps/ unfortunately I can't send you a part of app to reproduce this issue... this is a huge corporate level BIM-system.