Forum Discussion

jcmaine's avatar
jcmaine
New Member
6 years ago

Losing focus

I'm pretty new to Test Complete.  I'm trying to do some keyword testing and record some tests.  Haven't done any script writing yet.  I've recorded a test that selects a Tab and inputs bad data to cause a popup error message with a message and an OK button.  When I recorded it, I selected the OK button to close the error message.  When I play it back, the OK button is never selected and the error message stays open.  

 

Forgot to mention that I'm using Test Complete 12.50.4142.7

 

Any suggestions?

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Classic problem:

     

    When you are doing the actions manually, including while you are recording, you are taking cues from what you see on screen to know when it is "legal" for you to click on that OK button.  You wait for the modal form to appear, for the button to become enabled, etc.  So, manually, everything works fine and records fine.

    HOWEVER... TestComplete isn't quite that "smart".  When you playback what you record, TestComplete attempts to execute things as FAST as possible... this means that it doesn't always wait a sufficient amount of time for the object to be available for interaction.  So, it attempts to act before the application is ready for it.

     

    With Web Applications, sometimes buttons are present ("Exist") but are not visible and so TestComplete sometimes "clicks" on such things even though they aren't really there... so you get what APPEARS to be a successful test but it really isn't.

    So... you need to "wait" for the object to be available.  This is code/commands you have to manually add in after the recording to instruct TestComplete to delay.  There are several ways of doing so... the easiest and most blunt is to simply add a "Delay" action before the button click.  But I wouldn't recommend this because sometimes the object is available sooner than others.

    I would recommend adding a "WaitProperty" action on your OK button prior to attempting to click it.  In that WaitProperty, have it wait for "VisibleOnScreen" to be true that should "fix" your problem.

    For more information, check out https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/index.html