QTP .NET 4.0 Fail
Crash! My machines had been recently upgraded with .NET Framework 4.0, after which it seemed all QTP tests were failing, when they had run just fine against the previous version of .NET 3.5. After trying a few things, I noticed that when I spied on some of my apps fields that the object recognition was all wrong.
SwfWindows were now Window objects. Also — all of my SwfButtons and SwfEdit were being recognized as generic SwfObject. Uggg! So goes the life of an automation engineer. Here’s a quick example of what the object recognition was for .NET 3.5:
But in QTP for .NET 4.0, this was what was recognized:
So what happened?
After doing some research, it turned out that this issue was caused by the .NET framework being installed after QTP was installed – apparently not a good idea.
How do I fix this mess?
Well, of course HP’s position is that it’s best to install .NET 4.0 before you install QTP — but that’s not going to help testers like me that have a bunch of lab machines already configured with QTP.
To get .NET 4.0 and QTP to play nicely together (if your .NET 4.0 was installed after your QTP), you can manually register the following .NET DLLS (FYI: if you’re using a 64bit OS you’ll first need to first install the patch QTP_00709):
- To perform this fix you’ll will need to manually register two DLLs:
- Open the command prompt and type cmd.
- Navigate to the directory that contains Mercury.QTP.Agent.dll and Mercury.QTP.WpfAgent.dll:
- Next type in the following commands:
..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.Agent.dll
..\..\bin\GACRegUtil4x86.exe -i Mercury.QTP.WpfAgent.dll
What if that doesn’t help?
If the above doesn’t work, HP Support strongly recommends performing a clean un-install of QTP then install .NET 4.0 and reintall QTP.
Check out my posts How to do a clean uninstall of QTP and Everything you wanted to know about installing QTP