Ask a Question

Key Method no longer working for Web Module

Occasional Contributor

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
End If
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"

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?


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".

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

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 differencepsswordbox.JPG


Standard syntax disclaimers apply
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.

Sometimes the simplest option is simply the one that works Smiley Happy

Standard syntax disclaimers apply
Showing results for 
Search instead for 
Did you mean: