UIAutomation not always recognized

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

UIAutomation not always recognized

Post by RobinHellen » Tue Sep 13, 2011 9:56 am

HI, I'm having trouble automating an application written with WPF (Our AUT is a plugin to this.) The application has a group of tabs in a sort of MDI area. I was accessing this with the RanoreX path "container/tabpagelist[@automationid='DocumentGroup']" applied to the main form, but it was not finding the element about half of the time. Removing the automationid predicate allows RanoreX to always find the tabpagelist adapter, but it, and all elements under it do not have the UIAutomation capability.

both AUT and test code are 32-bit. RanoreX version is 3.0.4
This happens on both Windows 2008 R2 and Windows 7, but only when I am running test remotely, I can never get it to happen on my local development machine.

Do you have any ideas as to why the identification is inconsistent?

Thanks
Robin

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

Re: UIAutomation not always recognized

Post by Support Team » Wed Sep 14, 2011 8:53 am

Hi,

There is a similar topic to yours, can you please take a look at it because maybe you will find a useful hint.
http://www.ranorex.com/forum/test-faile ... t2594.html
Removing the automationid predicate allows RanoreX to always find the tabpagelist adapter
Can you check if the automationid is changing after a restart of your AUT (application under test)?
Are there any other unique attributes that you can use to find the specific elements?
Please update to our new 3.1 version and try it again.
Could it be that this is a timing issue, maybe Ranorex takes longer to find the elements on your remote machine (less computing power), have you tried to increase the timeout or to add a validation step before you perform an action?

Regards,
Markus
Ranorex Support Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Wed Sep 14, 2011 9:31 am

Hi Markus

Thanks for getting back to me. The AutomationID does not change after a restart. My tests see either an automationid of 'DocumentGroup' or none at all using the following code:

Code: Select all

            TabPageList pages;
            if (m_ApplicationForm.TryFindSingle("container/tabpagelist", 10000, out pages))
            {
                UIAutomation automatedList = pages.As<UIAutomation>();
                Assert.NotNull(automatedList);
                Assert.AreEqual(automatedList.ClassName, "DocumentGroup");
                return pages.Find<TabPage>("tabpage");
            }
I either get a failure from the first assertion (the conversion to UIAutomation returns null) or teh code runs through with no problem.
I've increased the timeout from its original 5s, and the code was already in a retry loop, which tried 10 times and each time gets the tabpagelist, but cannot convert it to UIAutomation.

Unfortunately there are no other unique attributes I can use for this control. I've had a look at the other topic and the executables are definitely both x86, The .config file is not set, but it is also not set on my local machine where I never run into the problem. I will try using Ranorex 3.1 first as the exectuing program on remote machines comes from a framework we wrote here that I don't know much about the internals of.

Thanks again

Robin

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

Re: UIAutomation not always recognized

Post by Support Team » Wed Sep 14, 2011 1:18 pm

Hi,

I have tried to reproduce your issue on my machine, but in my case everything works as expected.
So are you sure that the capability is UIAutomation?
Can you send us a Ranorex Snapshot file of the tabpagelist and the exact failure message?

You can also try to use these code for validation:
Validate.Attribute(YourElementInfo, "ClassName", "DocumentGroup");
Or you can try to "manually" compare the two strings:
if(!automatedList .ClassName.Equals("TextBlock")) Debug.Assert(false, "not equal" , "a different String");
Maybe something is wrong with your custom Assertion?
Which .Net Framework are you using, maybe your local machine has a different version than the remote one?

Regards,
Markus
Ranorex Support Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Wed Sep 14, 2011 2:57 pm

Hi Markus,

I've attached a snapshot of the application
The capability is definitely UIAutomation, as I said about half the time the code I posted before will run fine, but the rest of the time it fails as I said. The Assertion is a standard NUnit assert, givving the error message:
Expected: not null But was: null at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args) at NUnit.Framework.Assert.NotNull(Object anObject, String message, Object[] args)
Both local and remote machines have both .Net 3.5 and .Net 4.0 installed.

I have tried the .config file suggestion from the other topic, but it does not seem to have made a difference.
I will try upgrading to 3.1 next

Thanks

Robin
Attachments
SSMS Denali.rxsnp
(587.52 KiB) Downloaded 230 times

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

Re: UIAutomation not always recognized

Post by Support Team » Thu Sep 15, 2011 9:00 am

Hi,

please keep us informed if something has changed after the update.
Thanks for the snapshot!
As you can see from the snapshot the "ProcessArchitecture" is 64bit and the "RuntimeVersion" is .Net 4.0. So please consider the Reason #4, #5 and #6 in the general troubleshooting section.
Please build your tests for the remotely machine with the appropriate bit settings.
Can you also try to use these RxPath instead of your one "container[@classname='DockRoot']/tabpagelist[@classname='DocumentGroup']", because otherwise Ranorex has to search for the tabpagelist element in all the available containers.

Regards,
Markus
Ranorex Support Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Thu Sep 15, 2011 3:37 pm

Hi Markus, the upgrade to v3.1 has not helped

I've checked the general trouble shooting section:
#4: The test process and the AUT are both 32-bit.
#5: Both local and remote machines have the .NET 4.0 extended framework
#6: I've added the .config settings and that has not helped either

I've attached a snapshot of the AUT when I get the error. As you can see, the form and all the controls in this instance do not have the UIAutomation capability, but do have Accessible.

many thanks

Robin
Attachments
TabsError (6e69e62a-6962-41f6-ab45-bc27fb589c58).rxsnp
(15.81 KiB) Downloaded 215 times

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

Re: UIAutomation not always recognized

Post by Support Team » Thu Sep 15, 2011 4:39 pm

Hi,

So the conversion to the UIAutomation fails because it has an other capability.
It seems that the machines specifications are not the same, as you can see with spy.
First snapshot from your Win7 machine:
ProcessArchitecture: 64bit
RuntimeVersion: 4.0
and from your Win 2008 Server:
ProcessArchitecture: 32bit
RuntimeVersion: 2.0
You can check this, you only have to compare the root elements (Host) of the two systems in Spy.
So try to install/use the same frameworks, because the two root elements must be equal at least the properties above.
Therefore it seems that you haven't installed the .Net 4.0 framework on the server and it seems that you are running another version of your software (32bit)?
Are you using the same test executable on the two systems?

Regards,
Markus
Ranorex Support Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Fri Sep 16, 2011 9:45 am

Hi Markus.
I've attached three new snapshots created during my test run (actually created by the tests themselves, my first snapshot was made using RanoreX spy.)
TabsLocalGood is a snapshot created on my local machine with the code passing
TabsGood and TabsError are both created on the same remote machine during the same run of the test executable. The only difference is that the AUT has been restarted between the two.
So it shows that both runs are occurring on Win 7 64 bit, with a 32-bit executable, and .NEt runtime 2.0

The test executable is not the same between the two systems. On my machine I am running instandard NUnit GUI (2.5.7), on the remote machine it is a customised version of pnunit, but I have run with the same NUnit GUI and get the same results.

Robin
Attachments
TabsError.rxsnp
Remote machine, test fails
(15.79 KiB) Downloaded 256 times
TabsGood.rxsnp
Remote machine, test works
(364.21 KiB) Downloaded 213 times
TabsLocalGood.rxsnp
Local machine, test works
(364.89 KiB) Downloaded 265 times

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

Re: UIAutomation not always recognized

Post by Support Team » Fri Sep 16, 2011 1:11 pm

Hi,

Maybe the application is started with different security rights?
Therefore please disable the UAC or try to start the application with administrative rights, in both cases.
Can you reproduce this issue with a small sample application, check whether the elements are equal (in Spy) after a restart of the sample app?

Regards,
Markus
Ranorex Support Team
.
Image

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Fri Sep 16, 2011 4:28 pm

Hi Markus,

On the remote machine the test executable and the AUT are executed as administrator with elevated rights. It seems on my local machine as though I do not have elevated rights when running the tests. I've just tried running the tests with elevated rights locally, and that does not produce the error.

I don't think we can produce a sample app to demonstrate, as we don't use WPF internally here, it's an application we're plugging into, although you can download it (CTP3 of Sql Server Management studio for Denali) here: https://www.microsoft.com/betaexperienc ... 3CTA/enus/

Robin

RobinHellen
Posts: 9
Joined: Tue Sep 13, 2011 9:42 am

Re: UIAutomation not always recognized

Post by RobinHellen » Tue Sep 20, 2011 1:10 pm

Hi,

I've just tried an experiment, and downgraded to Ranorex 2 (2.3.9) and the tabpagelist is consistently recognised, and everything works fine (in that part of the AUT). Unfortunately, I need to be able to use RanoreX 3 as for other components I need to the use UIAutomationValue capability, which was not available in version , for some UI elements.
(I've attached a snapshot as created by RanoreX 2 on the same machine as where I've been having problems with RanoreX 3.)

Hope this helps with finding and fixing the problem

Robin
Attachments
TabsGoodOld.rxsnp
(160.57 KiB) Downloaded 191 times

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

Re: UIAutomation not always recognized

Post by Support Team » Thu Sep 22, 2011 11:08 am

Hi,

I have downloaded the Denali SQL Database and i have tried to reproduce the problem but in my case everything worked as expected if I use the right tools (the right bit version 32bit).
So if you are also using the right settings and if you still getting the error I would suggest to hold an online meeting next week, if it is okay for you?
You can also answer to our [email protected] mail address.

Regards,
Markus
Ranorex Support Team
.
Image