Forum Discussion

shenyusun's avatar
shenyusun
Contributor
9 years ago

Unable to get the object when the software is in (Not Responding) state

Hello beautiful people,

 

I am running to an issue that I am unable to get the 'Yes' button with the software that I am testing.

 

Basically, when I click a certain button in the current software, it will pop up another message window with 'Yes' or 'No' buttons.

 

However, when the message window is appeared, the software became (Not Responding) unless I click 'Yes' or 'No' buttons in the message window.

 

When I tried to get the object in the message window by recording the script, it's showing that below:

# Click 'Yes' button
NameMapping.Sys.Process("dwm").Window("Ghost", "ProgramName (Not Responding)", 1)

 

If I use Object Spy, then TC would hang until I manually click 'Yes' button in the message window, and then the software is out of Not Responding state.

 

Any suggestion? 

  • bbi's avatar
    bbi
    9 years ago

    About keys not working, don't use the testobject Keys but use the LLPlayer instead of.

     

    This insert a WM_Key message directly in windows loop and thus by-pass any code restriction 

     

    So to send a real ENTER key press to system ;

     

    LLPlayer.KeyDown(VK_RETURN, 5);
    LLPlayer.KeyUp(VK_RETURN, 5);

    First parameter is virtual key code, list of them is here.

    Second optional parameter is delay, better to use it to simulate real-life press which is not INSTANT.

     

    BTW you can use the same for mouse message, so a left click is:

     

    LLPlayer.MouseDown(MK_LBUTTON, xcoord, ycoord, 25);
    LLPlayer.MouseUp(MK_LBUTTON, xcoord, ycoord, 25);

    First parameter is the mouse button.

    Second and third parameters are coordinates.

    Fourth parameter is delay, better to use it to simulate real-life press which is not INSTANT.

     

    Be careful, the mouse or keyboard event is sent to the system and thus is treated by the currently active windows.

     

    For a clik or a press, you need always to do both actions, down and up 

     

    For more information, search for LLPlayer in TC help.

     

    Hope it helps.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Well, if you recorded the test and it actually captured the window name, it should capture the buttons as well. What happens if you go through the process of recording the whole thing? Does that get you your object name?

    As it is, the window you are working with is, IIRC about such things, this is a modal window served up by the OS (the DWM is the Desktop Window Manager from the OS) and is reporting to you that there is something not right with your application. Honestly, IMO, you should figure out why your application pops up that window and ends up in a non-responsive state...seems like a problem with the application.

    Otherwise, check out Testing Modal Windows for some techniques to use in doing your test.

    • shenyusun's avatar
      shenyusun
      Contributor

      Thanks Robert,

       

      If I record the whole thing, it did not captured the window name, and did not capture the buttons too.

      It'll skip that part somehow. It'll record everything except the execution in that window.

       

      The application pops up that window by design, it is saying there's better option, would I like to do it, Yes or No.

       

      I will check out Testing Modal Windows to see if I can find some workarounds.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        There is an option under Project Properties -> General labeld "Record user actions over tested applications only". What is that set to? 

        If that is checked, since the window you are referencing is not (supposedly) one of your tested applications, then it won't record the actions against it. If that is unchecked, you should be able to record the actions against any application that you interact with in the environment.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > If I use Object Spy, then TC would hang until I manually click 'Yes' button in the message window, and then the software is out of Not Responding state.

     

    Most probably, implementation of this window is that it waits to be closed via explicit click on the button but not via usual messaging mechanism of Windows. Thus, the tested application is blocked in the waiting thread and TestComplete cannot drive it.

    I would suggest to try to handle this window asunchronously via the CallObjectMethodAsync() method (https://support.smartbear.com/testcomplete/docs/scripting/calling-methods-asynchrounously.html, https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/script/runner/callobjectmethodasync.html).

    • shenyusun's avatar
      shenyusun
      Contributor

      Hello AlexKaras,

       

      I read through CallObjectMethodAsync link, but did not quite get it how to use it.

       

      It looks like I still need to get the window object in order to use CallObjectMethodAsync().

       

      When I tried to record any actions in the modal window, it returns:

      (In Python)

       

      Test1():

          pass 

       

      It did not get anything from key press or mouse clicks.