tryFindSingle failure when run from CLI

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ryan.such
Posts: 2
Joined: Fri Nov 15, 2013 9:30 pm

tryFindSingle failure when run from CLI

Post by ryan.such » Fri Jan 31, 2014 5:39 pm

Hello,

Our team has primarily been developing and running our Ranorex Suite from the Ranorex IDE. Recently, we decided to tie in our suite into our Jenkins CI system. I have been exploring a couple different options to do this, one is using Nunit to run the system for us, or secondly having a home built system that we would run from the Ranorex Command Line.

As I was exploring both options, I found that our search functionality doesn't seem to be working properly. We use tryFindSingle searches to identify all of our elements on our application. Since these searches require an object to start the search from, we also have a basic function that just finds our application. The function that searches for our app, has never had any issues at all when run from the Ranorex IDE, but as soon as I try to run it from CLI, or have Nunit run it(which I presume is just calling the CLI as well), the app can not be found.

Here is the Code in Question:
public static WindowsApp getVeevaApp()
{
        WindowsApp app = null;
        Ranorex.Host.Local.TryFindSingle<Ranorex.WindowsApp>("/winapp[?'" + "Veeva" + "']", 2500, out app);
        	return app;
}
Our application is called Veeva CRM, but used to be called VeevaMobile internally. Since the application is very new, and still open to a lot of changes, I wanted the search to be more general, to cover any possible changes in name/etc. That is the reason for the wild card search. I've also tried using the PackageName to identify, or other attributes, and have also adjustedthe search time all the way up to 10000ms to give it more time to find the application. Every single version of my searches has worked fine when run through the IDE, but fails every time when run from CLI or Nunit.

Has been tested on 2 different Windows 8.1 Professional VMs
Both are running Ranorex 4.1.4

Any ideas what could be happening here?

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

Re: tryFindSingle failure when run from CLI

Post by Support Team » Sun Feb 02, 2014 12:03 pm

The reason for this issue is Windows 8 app security: You need special rights to access and automate Windows 8 apps. The Ranorex tools have those rights, but your compiled executable probably does not.

Please see the following proposed solutions to this issue (Windows Apps - Reason #3) in the General Troubleshooting sections in the user guide:
http://www.ranorex.com/support/user-gui ... html#c4709

Regards,
Alex
Ranorex Team
.
Image

ryan.such
Posts: 2
Joined: Fri Nov 15, 2013 9:30 pm

Re: tryFindSingle failure when run from CLI

Post by ryan.such » Mon Feb 03, 2014 11:10 pm

Thank you for the quick response. The troubleshooting guide helped to get the application to run via CLI. I had to add the following code to the program.cs file:
if (Ranorex.Core.Util.IsRestartRequiredForWinAppAccess)   
 return Ranorex.Core.Util.RestartWithUiAccess();
Unfortunately, I'm still getting the same errors when run from Nunit. I suspect there is still some Windows 8 security issues happening, but haven't been able to track it down so far.

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

Re: tryFindSingle failure when run from CLI

Post by Support Team » Wed Feb 05, 2014 6:24 pm

Hello ryan.such,

The problem could be that you have to start NUnit using the UiaLauncher as well, for example using the command line. I am not exactly sure, but it should also work if you start Visual Studio as administrator.
I hope this will solve your problem.

Regards,
Bernhard
.
Image