Unable to find a control when trying through MStest.exe

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
sherinjab
Posts: 23
Joined: Wed Oct 08, 2014 2:57 pm

Unable to find a control when trying through MStest.exe

Post by sherinjab » Tue Sep 15, 2015 5:33 pm

Hi,

I'm facing a weird issue where a Combobox which is identified when I run my test on Visual Studio cannot be identified when I run the same test via command line using mstest.exe.
I even tried debugging the issue by attaching to the Mstest process, but there is no other problem but just that it cannot find the element for the given RxPath (I verified again during debug from Spy and it seemed to be the right one and element was highlighted correctly.)
The same test works fine when I execute it on Visual Studio.
Note: It can identify another button on the same form but the issue is just with this combobox.

Has anyone else faced such an issue?

Thanks,
Sherin

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

Re: Unable to find a control when trying through MStest.exe

Post by Support Team » Wed Sep 16, 2015 1:05 pm

Hi Sherin,

May I ask you to also send us more detailed information about your test environment?
Which OS and Ranorex version do you use?
What kind of application are you testing, WPF, Winforms,...?

This sounds for me like a permissions, security issue. Can you try to start the MSTest.exe and the test.exe as administrator, one of the following Solutions may also help here: Windows Apps - Troubleshooting.
Depending on the technology of the AUT, Ranorex tools and the Ranorex tests need to run with the same user as the test exe does, so please make sure this is also the case when you start the test with mstest.exe.

Regards,
Markus
.
Image

sherinjab
Posts: 23
Joined: Wed Oct 08, 2014 2:57 pm

Re: Unable to find a control when trying through MStest.exe

Post by sherinjab » Thu Sep 17, 2015 12:07 pm

Hi Markus,

Thanks for the suggestions and even I agree it seems to be something related to security or permissions. I'm using Ranorex 5.4.1 currently testing on Windows 8 but I tested on Widnows 7 and it's the same behaviour on both.My AUT is a Windows application with many WPF controls but this particular form and the control with the issue is a Windows control
I need my AUT to be loaded as an administrator so I added the following line of code to achieve it :

Code: Select all

    if (Environment.OSVersion.Version.Major >= 6)
                {
                    processStartInfo.Verb = "runas";
                }
This does the job for me as I'm now able to do the actions in my application which would have been possible only as an administrator. This requires that when I load VS I need to run it as an administrator and so I configured even mstest.exe to always run as administrator by enabling the "Run this program as an administrator" option in it's Compatibility tab. Doing all this is what helped my test to work until it reached the control with the issue.
I had also done the same for the Ranorex Spy tool but changed it after going through Reason 4 in the link sent by you stating
You checked the "Run this program as an administrator" in the Compatibility settings of a Ranorex Tool EXE file, e.g. for the RanorexStudio.exe file. Setting this option disables access to Windows 8 UI apps.
. I then created a shortcut for Ranorex Spy but then I'm not sure how will my mstest.exe refer to this shortcut.
So in summary, right now I've my AUT and mstest.exe running as administrator but not sure how to make Ranorex tools run as administrator too without changing the property in it's exe.

Thanks,
Sherin

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

Re: Unable to find a control when trying through MStest.exe

Post by Support Team » Thu Sep 17, 2015 4:58 pm

Hi Sherin,

I assume the app is no Windows8 UI (Metro) app, so using "Run this program as an administrator" to start Spy as administrator should be fine then.
I am afraid I don't understand what you mean with: "I'm not sure how will my mstest.exe refer to this shortcut".
You start the Ranorex test exe with mstest.exe and not Spy, right? Or did I get this wrong?
In my point of view you just need to make sure that the Ranorex test exe is also started as admin by mstest.exe.

How do you start mstest.exe, via the CMD or in code?
When you start it via CMD you could also start the CMD as administrator.

Regards,
Markus
.
Image

sherinjab
Posts: 23
Joined: Wed Oct 08, 2014 2:57 pm

Re: Unable to find a control when trying through MStest.exe

Post by sherinjab » Fri Sep 18, 2015 11:55 am

Hi Markus,

I start the mstest.exe via CMD and I had set both CMD and mstest.exe to run as Administrator same as the application but it still doesn't work. I find it weird how it's not able to identify this control while it can access other windows controls in the same form.
I've attached a snapshot of the control, in case you would like to have look at it.

I also tried by running all the applications (VS, AUT,mstest,cmd) without being an administrator and even in this case, it works through Visual Studio but not through mstest.exe
Thanks,
Sherin
Attachments
AdminDatasourceSnapshot.rxsnp
Snapshot of the combobox control with the issue
(96.6 KiB) Downloaded 61 times

sherinjab
Posts: 23
Joined: Wed Oct 08, 2014 2:57 pm

Re: Unable to find a control when trying through MStest.exe

Post by sherinjab » Mon Sep 21, 2015 3:06 pm

Hi,

Anyone who can help me on this?Still not been able to resolve the issue.

Thanks
Sherin

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

Re: Unable to find a control when trying through MStest.exe

Post by Support Team » Mon Sep 21, 2015 3:48 pm

Hi Sherin,

For me this seems to be more a question of how to tell mstest to elevate privileges to the process started by mstest.

In order to analyze this in detail, may I ask you to send me an email to [email protected], with a Ranorex snapshot of the specific element?
Here you can see how to create a snapshot: How to create a Ranorex Snapshot.

Thanks,
Markus
.
Image

sherinjab
Posts: 23
Joined: Wed Oct 08, 2014 2:57 pm

Re: Unable to find a control when trying through MStest.exe

Post by sherinjab » Thu Nov 05, 2015 6:04 pm

This issue was resolved after wasting many days but the cause of the issue was due to the difference in RxPaths generated between Ranorex Studio and Spy.
When I used the RxPath as used by Studio, even mstest could find the control and the test ran successfully

jazz albert
Posts: 3
Joined: Tue Nov 08, 2016 1:00 am

Re: Unable to find a control when trying through MStest.exe

Post by jazz albert » Tue Nov 08, 2016 1:03 am

sherinjab wrote:This issue was resolved after wasting many days but the cause of the issue was due to the difference in RxPaths generated between Ranorex Studio and Spy.
When I used the RxPath as used by Studio, even mstest could find the control and the test ran successfully
I still facing this issue and little confused about the aforementioned pathway!
TragusInfantigoRx
Last edited by jazz albert on Wed Nov 09, 2016 10:08 am, edited 1 time in total.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3947
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Unable to find a control when trying through MStest.exe

Post by odklizec » Tue Nov 08, 2016 8:36 am

Hi,

Unfortunately, there is too little information in your post, so there is not much anyone here can do for you. Please answer the following questions:

Technology under test (desktop/web/mobile - specify used technology - java, wpf, mfc, qt, etc...)?
What's your Ranorex version and OS version?
Could you please post an "EXACT" error message you are getting?
If Ranorex fails to find an element, please post the "EXACT" failing xpath and make sure the xpath exists on target system (via Spy, at a time of failure).
Please post a Ranorex snapshot (taken via Spy) of the element in question.
If you run the test on different computer than you designed the test, make sure both computers are configured the same way (Ranorex settings, OS settings, installed version of .net, etc...).
Difference in Ranorex settings is a most common reason of issues like this.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration