Forum Discussion

jsc's avatar
jsc
Regular Contributor
12 years ago

which command is send when using Aliases.SomeForm.Close()?

Hi all,



can anyone tell me, which command TestComplete uses to close a window when calling "Aliases.SomeForm.Close()" in the script?



I have to reproduce some incorrect behaviour outside of TestComplete and therefore need the function to make a standalone script that shows the problem.



I did not find anything via google or searching the forum.



Best regards,

Joachim
  • If I understand correctly, you have the same version of the TestComplete and you didn't change the scripts, but script works differently on two versions of your Tested Application.



    If that is the case, then something was changed in your tested application.



    As I said, Close method behaves the same way as if you clicked the close button .



    I don't know how your SomeForm is identified in your NameMapping, but the reason may be that in the new application version another window corresponds to this object. But even in this case, something changed in the application, not in TestComplete, and you will probably need to update NameMapping objects according to the changes in your application.
  • jsc's avatar
    jsc
    Regular Contributor
    I changed my scripts like that:



    before: Aliases.SomeForm.Close()

    now: Win32API.SendMessage(Aliases.SomeForm.Handle,16,0,0)



    Running the procedure in the scriptextensions is working fine.

    Calling the scripts from the keyword tests is not working, it says "Win32API is undefined"



    What did I do wrong?
  • Hi.



    Alexei, I never understood why those objects are not avalaible in script extensions context.

    I read the objets Available to script extensions page http://support.smartbear.com/viewarticle/27796/



    Joachim, an easy solution is to store the missing obect in a script extensions run time object property.

    Win32Api for instance become MyRunTimeObject.Win32Api. Then I assign the MyRunTimeObject.Win32Api with Win32Api in a OnStartTestMethod for instance.



    When i would use Win32Api in a script, i switch to MyRunTimeObject.Win32Api in the script extensions source code.

    Works fine. Can't see why i can't be done automatically actually.



    Regards,



    Guillaume.



  • jsc's avatar
    jsc
    Regular Contributor
    unfortunately it's not just WM_CLOSE.



    The problem is, that my test with a new version of the tested software the Aliases.SomeForm.Close() not just closes the form but the complete program as well.

    In the previous version of the tested software Aliases.SomeForm.Close() just closed the form. unfortunately I cannot directly access the code and look up, what's the problem now.



    With manual testing there is no problem with closing the form...
  • karkadil's avatar
    karkadil
    Valued Contributor
    If I understand correctly, you have the same version of the TestComplete and you didn't change the scripts, but script works differently on two versions of your Tested Application.



    If that is the case, then something was changed in your tested application.



    As I said, Close method behaves the same way as if you clicked the close button .



    I don't know how your SomeForm is identified in your NameMapping, but the reason may be that in the new application version another window corresponds to this object. But even in this case, something changed in the application, not in TestComplete, and you will probably need to update NameMapping objects according to the changes in your application.
  • jsc's avatar
    jsc
    Regular Contributor
    Yes, this is the case. The software changed and my scripts now do not really work the same way.



    After talking to a developer, this was changed:

    before: .close closed the one form

    now: .close closes all open forms including the main window of the program



    this behaviour is unfortunately intended to be this way.

    So I have to adjust my script by using some different method to close the form.
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Joachim,



    > What did I do wrong?

    Nothing. Win32API object is just not accessible from script extension (see 'Objects Available to Script Extensions' help topic for more details. Strange, that it works from script test code...).