Forum Discussion

Yan01's avatar
Yan01
Occasional Contributor
6 years ago

Key Method no longer working for Web Module

Currently we are testing Web Application with Web Module using TestComplete. I has a simple test case that login HeadOffice through login page. 

Here is my script:

URL = "http://qa1-merch1/merchant/headoffice/test/login"
Call Browsers.Item(btChrome).Run
If Not Sys.WaitBrowser("chrome", 10000).Exists Then
Browsers.Item(btChrome).Run(URL)
Browsers.Refresh
Else
Browsers.Item(btChrome).Navigate(URL)
Browsers.Refresh
End If
Sys.Browser("chrome").BrowserWindow(0).Maximize
Set Browser = Sys.Browser("chrome")
Set Panelroot = Browser.Page(URL).Panel("container").Panel("root")
Set form = Panelroot.Panel(1).Panel(0).Form(0)
Set User = form.Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Textbox(0)
Call User.Keys("mgb")
Set Password = form.Panel(0).Panel(1).Panel(0).Panel(0).Panel(0).PasswordBox(0)
Call Password.Keys("wilko")
Set LoginButton = form.Button("loginSubmitButton")
Call LoginButton.ClickButton
Delay "10000"
Browser.Close

I am using Keys Method to enter user and password, it doesn't work anymore. I replace it with SetText, it works fine. So it seems Keys Method no longer works for our web application, but it works fine with Desktop module. Is there any reason, and how can fix it?

 

  • Yan01's avatar
    Yan01
    6 years ago

    The user textbox can not be used with Keys Action as well. But Keys action can be used in the main web page. I just simply change my script to use SetText instead of Keys Method and it works fine. Thanks for your help.

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    If you didn't change TestComplete versions, the problem is not with TestComplete.  The "Keys" method is not broken.

    My expectation is that something changed in your web application with security hardening of the login page.  There are any number of security items that would prevent a"scripted" entry of the password SPECIFICALLY to prevent exactly what TestComplete is doing... utilizing a non-hardware keyboard method of entering the password into a login form.  This is why "SetText" probably works because it sets the text internally on the property of the object rather than attempting to use "Keys".

    • RUDOLF_BOTHMA's avatar
      RUDOLF_BOTHMA
      Community Hero

      Further to tristaanogre :

       

      Did the textbox itself change from a textbox to a password box ?  They behave differently including, as tristaanogre suggested, disable scripting on the object. Attacched is a screenshot of my object tree to illustrate the difference

       

      • Yan01's avatar
        Yan01
        Occasional Contributor

        The user textbox can not be used with Keys Action as well. But Keys action can be used in the main web page. I just simply change my script to use SetText instead of Keys Method and it works fine. Thanks for your help.