Forum Discussion

RobertDAltman's avatar
RobertDAltman
Occasional Contributor
7 years ago

How do I wait for a user to perform an action?

In a Script test, how do I prompt the user to perform some action, then continue the script after the user indicates the action is complete?  For example, I need to interact with a CAPTCHA on a form, so I need to tell the user to satisfy the CAPTCHA then click on something to continue the automated test.

    • RobertDAltman's avatar
      RobertDAltman
      Occasional Contributor

      Builtin.ShowMessage doesn't seem to do what I want.  Here's my script:

       

       

      function Test1()
      {
        // Launch a website in Chrome
        Browsers.Item(btChrome).Run("http://www.indigo.health/");
      
        // Enter some data into the fields of a "contact us" form
        Aliases.browser.pageWwwIndigoHealth.formForm.textboxEmail.SetText("rdaltman@gmail.com");
        Aliases.browser.pageWwwIndigoHealth.formForm.textboxEmail.Keys("[Tab]");
        Aliases.browser.pageWwwIndigoHealth.formForm.panel.panel.panel.textareaComment.Keys("Hi Bob. This is a test");
      
        // The submit button has a hidden ReCaptcha on it;
        // Tell the user to manually click the button so that the CAPTCHA magic is happy
        BuiltIn.ShowMessage("Click the button!");
        
        // Continue the script... Click on a button to go to another page
        Aliases.browser.pageWwwIndigoHealth.panel.panel.textnode.Click(120, 23);
        Aliases.browser.pageWwwIndigoHealthPatientInfoHt.Wait();
      }

      Up to the point where I call ShowMessage, things proceed as expected.  It displays my web page and populates the text boxes.  But when ShowMessage executes, the web page under test loads some oddball website while the TestComplete IDE is displayed with the message box in front of it.  I can't click the button because it's no longer on the displayed web page.

       

       

      • karkadil's avatar
        karkadil
        Valued Contributor

        This sounds very strange, the ShowMessage method should't interfere with browser.

        Could you please show us screenshot of the both TestComplete and Crome at the moment when message displays?

         

        Also, you can try using User Forms, but make sure you show the user form in modal view.

    • RobertDAltman's avatar
      RobertDAltman
      Occasional Contributor

      Since the answer included two options (breakpoint or while loop), I just want to point out that my "accepted" solution is the "while loop" plus a message displayed in the TestComplete Indicator.  That solution simply pauses the automated interaction with the web page until the user does something detectable by the while loop.  In my actual test case, I need to click a button protected by a CAPTCHA, which causes my website to redirect to a different page.  In the case of the example I posted (to illustrate a bug I ran across), clicking on the button causes the button to be hidden.  In either case, I can poll in the while loop waiting for the condition to exist (with timeout logic, etc.).

       

      On a related subject: Suppose I want to pause to allow a user to enter a password in a form.  Assuming that the only action I want the user to manually perform is to enter the password, what can I test for to terminate the while loop?

       

       

      • karkadil's avatar
        karkadil
        Valued Contributor

        As an example - the length of the text in the text field, but you should know it, of course