QTP .NET 4.0 Object Recognition Issues

QTP/UFT Published on:
UFT UPdate

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:

SwfWindow(“Patient”).SwfButton(“New Reg”)

But in QTP for .NET 4.0, this was what was recognized:

Window(“Patient”).SwfObject(“New Reg”)

So what happened with the .NET 4.0 issue with UFT?

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 UFT QTP .NET 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):

  1. To perform this fix you’ll will need to manually register two DLLs:
  • Mercury.QTP.Agent.dll
  • Mercury.QTP.WpfAgent.dll

  1. Open the command prompt and type cmd.

  1. Navigate to the directory that contains Mercury.QTP.Agent.dll and Mercury.QTP.WpfAgent.dll:
  2. 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 my QTP .NET 4 issue?

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

32 responses to “QTP .NET 4.0 Object Recognition Issues”

  1. Hi Joe – great site. I have issues with inconsistent object recognition of WPF objects. Sometimes QTP “sees” all properties as you’d expect, and other times (mostly) it just sees a wpfWindow, w/ nothing inside – very frustrating. I’ve had similar issues in the vb world. I’ve read enough forums to see that this is apparently quite common, and I have not seen any solutions. Surely not everyone using .net/wpf has this problem?

    I followed the steps you’ve outlined above – registered the dlls, then re-installed QTP, and it made no impact. I’m running v11.

    Can you shed any light on this?

    Thanks – Paul

    • Paul Greij » Hi Paul – I have not done any heavy WPF testing but I know another group in my company that has. They had to contact HP and get a bunch of hot fixes to resolve most of their issues. If there is not an official QTP WPF patch that helps you then you might want to contact HP support and see if there are any hot fixes for your situation.I know version QTP 11 is much better than 10 but I still think its a buggy add-in.

  2. Thanks for the reply Joe – I’ve been able to narrow this down a bit. If I launch the executable by dbl-clicking it, then QTP will recognize the WPF login window correctly (all properties and objects within), but if the QTP script launches the app – either systemUtil.run or wsh-shell.run, then the same window is just recognized as a generic WPF window, with no properties or contained objects. Any thoughts? Much appreciated.

  3. I am using QTP11, using 64 bit OS so installed patch QTP_00709 and QTP_00699 (Also I am sure I installed QTP before .NET framework 4) I followed the steps given by you to manually register the dlls

    For dll – Mercury.QTP.Agent.dll – I am getting an error on command prompt as ‘Could not load file or assembly Mercury.QTP.Agent.dll or one of its dependencies. The specified module could not be found’

    I cross checked the path of the exe – GACRegUtil4x86.exe
    and also the path of the dll – Mercury.QTP.Agent.dll

    I then tried for the other dll – Mercury.QTP.WpfAgent.dll
    and astonishingly this worked fine.

    I am facing exactly the same problem as mentioned in this page
    that is :Window(“”).SwfObject(“”)

    Kindly suggest me if i can do something to solve this issue.

    Thanks,
    Vidya

    • Vidya Bharambe » Hi Viday – unfortunately I’m out of ideas. Does any one else have any suggestions? You might want to contact HP support at this point. Cheers~Joe

  4. Shweta,

    I uninstalled QTP and .NET framework. I installed QTP then .NET framework (version 4 in my case). installed the patches QTP_00709 and QTP_00699. It worked for me…

    (uninstalling and reinstalling both QTP and .NET framework in proper order really helped)

    Joe’s info on this order of installation helped :)

    Thanks a tonne
    Vidya

  5. Hi ,
    I am working currently .net framework 4.0 application, there is problem to recognize the menu bar using QTP 11.
    When you select the menu bar , it get selected as “SwfObject”. So I am unable to select the items in the menu bar.

    Except menu and SwfTable, all other objects are recognized.

    I have followed ur steps adding “DLL” , but it haven’t worked out.
    The last option is need to uninstall .Net and QTP. may i know the order of installation? (either .net or QTP need to install first)

  6. Hi Joe,

    Can you please let me know, what version of .Net framework is originally supported by QTP 11?

    I have installed 0709 patch.

  7. Hi Joe,
    Im running QTP 10.00 on a Dot Net 3.5 app.
    I have a window with multiple SwfEdit boxes. I recorded a run where i keyed in data and tabbed from one swfedit field to another and on playing it back, i see that the swfedit boxes are cleared as soon as the cursor moves to the next swfedit. how do i tackle this ?

    I tried placing waitproperties, but to no use. copying the script generated below. Im new here and would love some pointers.

    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_1″).WaitProperty”enabled”, “True”, 20
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_1”).Set “joseph”
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_1”).Type micTab
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_2″).WaitProperty”enabled”, “True”, 20
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_2”).Set “sara”
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_2”).Type micTab
    Wait 3
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfObject(“Chinese (Simplified)”).Type micTab
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_3”).Type micTab
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit_4”).Type micTab
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfEdit(“SwfEdit”).Type micTab
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).SwfObject(“Next>>”).Click 58,20
    SwfWindow(“Officers”).SwfWindow(“Find Person Wizard”).Activate

    • nidhin » Hi what happens if you replace the .Set method with the .Type method–Do you get the same behavior?

  8. We have been facing the same above problem when working with swf object, we installed thrid party tool “Test advantage” meant for third party infragistics. its workng fine

  9. Hi Joe,
    Was there any clear solution to this issue? I am having the same problem of Swfobjects being recognized as only a swfobject.
    I am using QTP 11 on an application running .Net 4.0. Using Vista OS. I already tried the dll registering step. I have QTP_00709 and QTP_00078 patches installed as well. Is there another patch that can fix this issue?

    • SAntony » Hi this fix has always worked for me. I know this is lame but if the above doesn’t work, HP Support strongly recommends performing a clean un-install of QTP then install .NET 4.0 before re-intalling QTP.

  10. I tried to run the registry command but I was not able to run them below is the error msg I am geeting.I am not much into unix so could not figure out whats wrong.
    this is I am running
    ..\bin\GACRegUtil4x86.exe -i Mercury.QTP.Agent.dll

    and error I am getting is
    ‘..\bin\GACRegUtil4x86.exe’ not recognised as internal or external command

    • If you search your machine for GACRegUtil4x86.exe do you find it? If so are you sure the the path you are running from the cmd is correct and pointing to that location?

      • Yes, I can see the GACRegUtil4x86.exe file in the bin folder
        and this is the path where I found the DLL files and in CMD I am at the same path
        C:\Program Files\HP\QuickTest Professional\GlobalAssemblyCache(there is no Net 4 folder)
        The bin folder is just one folder before the GlobalAssemblyCache folder (in QTP folder)and in bin the exe file is present.

  11. Hi Joe,

    Please let me know if you have already worked in wpf based windows application

    my query is How to retrieve objects from a WPFGrid control in qtp. when spying, qtp is identifing only the WPFGrid and not the objects inside it. pls suggest workaround for this

    WpfWindow(“title”).WpfTable(“title”)

    Inside the wpftable there are Seven columns and some rows. Seventh column contains Edit/Export/Remove buttons. i want to click on any of the Edit/Export/Remove buttons,anything inside the wpftable are not recognized by object spy

    Regards
    Giriyappa

    • Hi, I have not worked with WPFGrid with QTP/UFT before. I did find some example code of others working with this control that might give you some ideas:

      Get the title of a column
      ‘Index are 0 to Count-1
      ColumnTitle = WpfWindow(“XceedGridTest”).WpfObject(“xGrid”).Object.VisibleColumns.Item( 0 ).Title Print ColumnTitle ‘or WindowName = WpfWindow(“XceedGridTest”).AutomationElement.Current.AutomationId
      GridName = WpfWindow(“XceedGridTest”).WpfObject(“xGrid”).AutomationElement.Current.AutomationId
      ColumnName = WpfWindow(“XceedGridTest”).WpfObject(“xGrid”).Object.VisibleColumns.Item( 0 ).FieldName Set columnManagerCellDesc = Description.Create() columnManagerCellDesc( “devnamepath” ).Value = “Cell_” & ColumnName & “;FixedHeader_1;” & GridName & “;” & WindowName & “;”
      Set columnManagerCell = WpfWindow(“XceedGridTest”).WpfObject( columnManagerCellDesc ) print columnManagerCell.GetVisibleText()

      ‘Sort a column simulating a user clicked on it WindowName = WpfWindow(“XceedGridTest”).AutomationElement.Current.AutomationId
      GridName = WpfWindow(“XceedGridTest”).WpfObject(“xGrid”).AutomationElement.Current.AutomationId
      ColumnName = WpfWindow(“XceedGridTest”).WpfObject(“xGrid”).Object.VisibleColumns.Item( 0 ).FieldName Set columnManagerCellDesc = Description.Create() columnManagerCellDesc( “devnamepath” ).Value = “Cell_” & ColumnName & “;FixedHeader_1;” & GridName & “;” & WindowName & “;”
      Set columnManagerCell = WpfWindow(“XceedGridTest”).WpfObject( columnManagerCellDesc )

      columnManagerCell.AutomationPattern( Invoke ).Invoke() ‘or columnManagerCell.Click

      ‘Column header will not always be in FixedHeader_1, it depend where the column manager row is added in the grid.

      —————————-

      ‘ Make the row current and selected
      WpfWindow(“Window1”).WpfObject(“grid”).Select “PersonFN3”

      ‘Change current column to last name
      Set ColumnLastName = WpfWindow(“Window1”).WpfObject(“grid”).Object.Columns.Item( “LastName” ) Set WpfWindow(“Window1”).WpfObject(“grid”).Object.CurrentColumn = ColumnLastName

      Set CurrentRow = WpfWindow(“Window1”).WpfObject(“grid”).Object.GetContainerFromItem( WpfWindow(“Window1”).WpfObject(“grid”).Object.CurrentItem )

      ‘Start edition on the current cell
      Set newCurrentCell = CurrentRow.Cells.Item( WpfWindow(“Window1”).WpfObject(“grid”).Object.CurrentColumn.FieldName )
      newCurrentCell.BeginEdit()
      ‘Type value in
      WpfWindow(“Window1”).Type “Test”

      ‘Force edition on FirstName
      Set newCellToEdit = CurrentRow.Cells.Item( “FirstName” )
      newCellToEdit.BeginEdit()
      ‘Type value in
      WpfWindow(“Window1”).Type “Test2”
      ‘Change to next cell
      WpfWindow(“Window1”).Type micTab

      ‘Enter edition of the new cell
      Set newCurrentCell = CurrentRow.Cells.Item( WpfWindow(“Window1”).WpfObject(“grid”).Object.CurrentColumn.FieldName )
      newCurrentCell.BeginEdit()
      ‘Type value in
      WpfWindow(“Window1”).Type “Test3”
      ‘Commit edition of the row
      CurrentRow.EndEdit()

      ———————————-
      ‘Here is a code snipet to get the CellValue based on RowIndex and ColumnIndex

      rowIndex = 0
      columnIndex = 0
      set cell = WpfWindow(“Window1”).WpfObject(“grid”).AutomationPattern( “Grid” ).GetItem( rowIndex, columnIndex ) set supportedPatterns = cell.GetSupportedPatterns()

      set valuePattern = nothing
      For i = 0 to supportedPatterns.Length – 1
      set tempPatern = supportedPatterns.GetValue( i )
      If tempPatern.ProgrammaticName = “ValuePatternIdentifiers.Pattern” Then
      set valuePattern = tempPatern
      Exit for
      End If
      Next

      cellValue = cell.GetCurrentPattern(valuePattern).Current.Value
      print cellValue

  12. Super and good job Joe!
    My question is every object in my application is identified as swfobject. But it is supposed to be a table because of this I’m not able to get the cell value which I need to select. So I cant use childitem.

  13. Hi Joe,

    When I login with my credentials. WPF object cannot be recognized by UFT 12.02. Those are identified as windows object.

    But on same machine for other user, objects are recognized correctly as WPF objects.

    I check all addins and other UFT settings are identical, but still I don’t know why am facing this issue

    Could you please help me to solve this issue.

    Thanks in advance

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

UFT UPdate