Forum Discussion

joffre's avatar
joffre
Regular Contributor
14 years ago

TestComplete Script Configuration

When I record my actions, TestComplete saves the following script:

Dim fpw5_cadcalc

Dim control

Dim control2

Dim control3

Dim edit

Set fpw5_cadcalc = Aliases.FPW5_CADCALC

Set control = fpw5_cadcalc.Form1

Call control.MainMenu.Click("Tabelas|Básicas|Empresas")

Set control2 = control.MDIClient.cdEmpresas

Set control = control2.Frame1

Set control3 = control.cboEmp

Set edit = control3.Edit

Call edit.Keys("[Caps]")

control3.wText = "NOME DA EMPRESA"

Set control = control2.fraDadosGerais

Set control3 = control.txtNomeFant

control3.wText = "NOME DA FANTASIA"

Set control3 = control.txtNumCAGED

Call control3.Keys("123")

Set control3 = control.txtNumFunc

Call control3.Keys("123")

Set control3 = control.txtDataRef

Call control3.Keys("10062011")

Set control = control2.fraTabProprias

Call control.chkIndTabProprias.ClickButton(cbChecked)

fpw5_cadcalc.dlgFPWCadastrosEC_lculosMensagem.btnOK.ClickButton

Call control.chkIndTabSalario.ClickButton(cbChecked)

control2.btnCadMod.ClickButton

fpw5_cadcalc.dlgFPWCadastrosEC_lculos.btnOK.ClickButton

control2.btnFechar.ClickButton




When my co-worker records the same actions, TestComplete saves the following script:

Call Aliases.FPW5_CADCALC.Form1.MainMenu.Click("Tabelas|Básicas|Empresas")

Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.Frame1.cboEmp.wText = "nome da empresa 546542"

Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraDadosGerais.txtNomeFant.wText = "fantasia"

Call Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraDadosGerais.txtNumCAGED.Keys("1321")

Call Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraDadosGerais.txtNumFunc.Keys("21")

Call Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraDadosGerais.txtDataRef.Keys("10062011")

Call Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraTabProprias.chkIndTabProprias.ClickButton(cbChecked)

Aliases.FPW5_CADCALC.dlgFPWCadastrosEC_lculosMensagem.btnOK.ClickButton

Call Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.fraTabProprias.chkIndTabSalario.ClickButton(cbChecked)

Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.btnCadMod.ClickButton

Aliases.FPW5_CADCALC.Form1.MDIClient.cdEmpresas.btnFechar.ClickButton




What do I need to change on my TestComplete's configuration to make my actions being saved like his actions?



He told me to go on Tools Menu and select Options. Then Engines > Name Mapping and check all the options, but it didn't work.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    See the screenshot attached.  It looks like your colleague has the "Do not generate variables" option checked while you have it unchecked.  
  • joffre's avatar
    joffre
    Regular Contributor
    Thanks again Robert. Worked perfectly!!!



    One more question about the script above:

    Aliases.FPW5_CADCALC.dlgFPWCadastrosEC_lculos.btnOK.ClickButton




    This line will press the OK button, but this dialog box will just appear if one condition is TRUE (in this case, it will appear if a company with the same name already exists).



    How do I insert a condition on my code to use this code line just IF the company already exists?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'd do something like this:



    if Aliases.FPW5_CADCALC.WaitAliasChild("dlgFPWCadastrosEC_lculosMensagem", 10000).Exists then

    Call Aliases.FPW5_CADCALC.dlgFPWCadastrosEC_lculosMensagem.btnOK.ClickButton





    This waits up to 10 seconds for the dialog box to display... if it doesn't display in 10 seconds, exists returns false and the button click is skipped.
  • joffre's avatar
    joffre
    Regular Contributor
    There are three environments that needs to be seen.



    1) If the company exists, and the dialog box appears instantly, my code will wait 10 seconds before doing the next step.

    2) If the company doesn't exists, my code will wait 10 seconds before doing the next step.

    3) If the company exists, but the dialog box doesn't apperas within 10 seconds, it will return an error.



    So... Is it possible to improve this code to fill all the environments?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    1) If the dialog box returns instantly, the code will complete instantly.  The 10 second delay is a maximum wait time.  If the WaitAliasChild returns in less than 10 seconds, it will not wait the full 10 seconds.

    2) This is correct.  It will wait all 10 seconds to see if the dialog comes up.  If this is too long a time frame, reduce the number.  It's in milliseconds so 5000 is 5 seconds, 10000 is 10 seconds, and so on.

    3) If it takes longer than 10 seconds for a dialog box like that to appear, then you might want to increase the timer to something longer.  Again, consider that the WaitAliasChild will wait up to that amount for the dialog to appear but will return if the dialog appears earlier.  In my opinion, if it takes longer than 10 seconds for a dialog box like that to come up, you have bigger problems in your application related to performance than simply if the dialog box comes up. :-)
  • joffre's avatar
    joffre
    Regular Contributor
    1) If the dialog box returns instantly, the code will complete instantly.  The 10 second delay is a maximum wait time.  If the WaitAliasChild returns in less than 10 seconds, it will not wait the full 10 seconds.

    2) This is correct.  It will wait all 10 seconds to see if the dialog comes up.  If this is too long a time frame, reduce the number.  It's in milliseconds so 5000 is 5 seconds, 10000 is 10 seconds, and so on.

    3) If it takes longer than 10 seconds for a dialog box like that to appear, then you might want to increase the timer to something longer.  Again, consider that the WaitAliasChild will wait up to that amount for the dialog to appear but will return if the dialog appears earlier.  In my opinion, if it takes longer than 10 seconds for a dialog box like that to come up, you have bigger problems in your application related to performance than simply if the dialog box comes up. :-)




    About answer number 3... lol .. it was junst an example. The window appears immediately. :)



    So, it is impossible to set my condition to wait for the new dialog box? I mean, it is necessary to have a wait time instead of just the dialog box wait...



    Thanks!
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    I'm not sure I understand your question.  The code I gave you is doing what you said: It's waiting for the dialog box to determine if the script should click the button. Is there something else you'd prefer it to do?
  • joffre's avatar
    joffre
    Regular Contributor
    I'm not sure I understand your question.  The code I gave you is doing what you said: It's waiting for the dialog box to determine if the script should click the button. Is there something else you'd prefer it to do?




    It is doing what I need.

    But, I was hoping that this function didn't need a timeout.



    Maybe there is a way to make a SELECT from the database and if the select returned FALSE, it will jump the codeline that press OK on the dialog box.



    Lets suppose that my database doesn't have no company named TESTCOMPLETE.

    Something like this... don't know how a SELECT will return TRUE or FALSE, but:

    result = SELECT * FROM COMPANYNAME

    If result <> "" Then

        Call Aliases.FPW5_CADCALC.dlgFPWCadastrosEC_lculos.btnOK.ClickButton

    End If




    Something like that ^^
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    The only problem I have with that methodology has to do with what you're goal of testing is.  Part of the feature set of your product is that, if the company does not exist, prompt.  You're bypassing that part of your application code that generates the dialogue box and kind of cheating it.  It will work and do what you want, but what if the company does not exist and the dialog box never appears?  Then your select query will return that the company exists and the script will try to click a button on a form that does not exist.



    You can do the select query as you mentioned, but I'd expand one step beyond and test for the existance of the dialog as well.  If the select query returns no records, then check with the Wait method to see if the dialog comes up.  If the dialog comes up, click the button and move on.  If the dialog does NOT come up, then you have a scenario that is actually a bug because a prompt that was supposed to generate did not.



    It all comes down as to what you are testing.
  • joffre's avatar
    joffre
    Regular Contributor
    I guess you are correct (once again).



    Here is what I'm testing on this window (attached for your knowledge).



    I'm testing if all the tables are created. So, I'll need to create some different companies to test everything (because of the radiobuttons).

    If I try to add a Company with the same name as an existing Company, my application must return me an error. It is doing that, but I'll have to do this test again on next version (that will be released next month) and with the next version after that (that will be released in october/november)...

    So, that is the idea of SELECT. I'll test if the application is doing what it needs to do to don't allow Company's name duplication.

    But I think other people will test it, so no worries.



    Thanks again.