Forum Discussion

steve_clarke's avatar
steve_clarke
Contributor
9 years ago

NetUIHWND issues - Saving an Excel worbook

I have a test, for a Delphi application, that invokes Excel in order to save a report created in the application.

Excel is closed and then the workbook should be saved, with a prescribed title, to a location on the hard drive.

Everything is fine up to the point of trying to Save. The script, in the test, closes the workbook at which point the MS Excel window (WndClass: NUIDialog with child window WndClass: NetUIHWND) appears offering the User the options of three buttons 'Save', 'Don't Save' & 'Cancel'. Herein lies the issue; TestComplete (Version 12.0.122.7 on WIN10, MS Excel2013) is unable to see any of the properties of that child window NetUIHWND. Not the caption (WndCaption) "Want to Save your changes to 'Book1' or the afore mentioned three buttons.

The result of this is that my test (automated) fails when trying to click the 'Save' button as it cannot be found.

I have tried running a script recording but all this does is reinforce the issue that TestComplete cannot read beyond the WndClass property of the child window as it records the click on the 'Save' button merely as a set of coordinates - which is of no use as it cannot be certain that the window will appear in exactly the same location every time.

 

Anyone else had the same issue and, if so, how did you get around it?

 

Cheers,

Steve.

  • Have you tried to use the buttons shortcuts ?

     

    Something like this:

     

    Sys.Process('excel').Window('NUIDialog', 'Microsoft Excel', 1).Window('NetUIHWND', '', 1).SetFocus

    Sys.Desktop.Keys('~S')

     

    This will enters 'ALT + S' (Save) into the control with focus. Or just the second line if the window is already focused.

  • S_Leonardo's avatar
    S_Leonardo
    Occasional Contributor

    Have you tried to use the buttons shortcuts ?

     

    Something like this:

     

    Sys.Process('excel').Window('NUIDialog', 'Microsoft Excel', 1).Window('NetUIHWND', '', 1).SetFocus

    Sys.Desktop.Keys('~S')

     

    This will enters 'ALT + S' (Save) into the control with focus. Or just the second line if the window is already focused.

    • steve_clarke's avatar
      steve_clarke
      Contributor

      Hi S_Leonardo,

       

      Many thanks for that bit of advice.

      It proved very useful as I can now save the worksheet and move on :-)

       

      I guess there is still an issue with TC not being able to focus beyond the initial child window class, however.

       

      Cheers,

      Steve.

  • I would expect that recording gives you coordinates, that's the usual thing.

     

    If you use Object Spy on the button, what path does it give you?  Post it here please.

    • steve_clarke's avatar
      steve_clarke
      Contributor

      Hi Marsha_R,

       

      Thanks for the reply.

      It's pretty much as described above. Firstly, here is the full name for the parent window:

      Sys.Process('excel').Window('NUIDialog', 'Microsoft Excel', 1)

       

      And now, the full name for the child:

      Sys.Process('excel').Window('NUIDialog', 'Microsoft Excel', 1).Window('NetUIHWND', '', 1)

       

      The actual window appears as per the attachment.

       

      Cheers,

      Steve.

       

      • Marsha_R's avatar
        Marsha_R
        Moderator

        Okay, next, is the button or either of those windows in your name mapping?

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    steve_clarke wrote:

    The script, in the test, closes the workbook at which point the MS Excel window (WndClass: NUIDialog with child window WndClass: NetUIHWND) appears offering the User the options of three buttons 'Save', 'Don't Save' & 'Cancel'. Herein lies the issue; TestComplete (Version 12.0.122.7 on WIN10, MS Excel2013) is unable to see any of the properties of that child window NetUIHWND. Not the caption (WndCaption) "Want to Save your changes to 'Book1' or the afore mentioned three buttons.

     

     


    Hi Steve,

     

    Try adding NetUIHWND to the MSAA window classes:

    1. Open the project properties > Open Applications > MSAA.
    2. Add NetUIHWND to the list and select the check box next to it.
    3. Save the project.

    TestComplete should see the objects in this dialog.

     

    • steve_clarke's avatar
      steve_clarke
      Contributor

      Hi Helen,

       

      Thanks for replying.

       

      I did as you suggested, in fact I added both NUIDialog and NetUIHWND (and checked both).

      However, the test script failed as before when trying to click the Save button.

       

      So far, the suggestion given by S_Leonardo seems to provide the best way forward.

       

      Cheers,

      Steve.