Forum Discussion

coffee's avatar
coffee
Contributor
9 years ago

Emulating Keyboard [Tab] for webpage

Hi,

 

I have a webpage with 3 input text boxes. 

User can put some string to the first text box and then hit [Tab] on the keyboard to jump to the second text box, put some string and then hit [Tab] again on the keyboard to jump to the third text box.

 

I am wondering how TC can do this.

 

I found this article https://support.smartbear.com/viewarticle/80629/ , but unfortunately this only applies to Desktop and Sys objects which I understand that it won't work with webpage objects (web testing). 

 

Anyway I just tried it 

 

var textbox1 = page.QuerySelector("input[type='text']");   //OK
textbox1.Click();  //OK
textbox1.value= "Hello"; //OK aqUtils.Delay(5000); textbox1.Keys("[Tab]");
//TypeError textbox1.Keys is not a function
 

 

Thank You

 

2 Replies

  • Something isn't right?

     

    I just tried this using: http://secure.smartbearsoftware.com/samples/testcomplete11/WebOrders/Login.aspx

     

    ... and [Tab] sent using the "Keys" method took me from the Username field into the Password field without any issues?

     

    I tried it both using "Keys" to enter a value into the Username field, but I also did it by setting the "Value" property directly (Which I wouldn't recommend. A user can't do this, they can only key values into the field. I use "Keys" for input 99.9% of the time as it's the most realistic user simulation.). Using "Value" it also worked fine.

     

    So I'm not sure what's going on with yours?

    • soccerjo's avatar
      soccerjo
      Occasional Contributor

      Agreed, I use Sys.Keys("keys here") in my web testing. Give it a try and let us know how it goes!