This is a migrated thread and some comments may be shown as answers.

Best way to clear HtmlInputText

3 Answers 155 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Miguel
Top achievements
Rank 1
Miguel asked on 25 Jun 2014, 09:16 PM
We are working with several elements with Java Script attached to them and I've found that sometimes the events associated with them require the user to physically clear the box for the change to register when saving. This is the same case when inputting which can be accomplished by using:
Manager.Desktop.KeyBoard.TypeText("some string", 50, 100, true);

As of right now I've overcome this by creating a manual step and referencing it within a script step as I haven't found a way to script a manual step:
this.ExecuteTest("_Shared Steps\\_Clear mask.tstest");

This, however, disables me from scheduling the test as someone has to complete the manual step for clearing out the HtmlInputText. In a similar thread it was suggested to set the text or value to "" but this is not an option as this boxes require physical input and hard codding a specific number of backspaces into my test doesn't feel like the correct solution.

Has anyone encountered similar issues and found a workaround?

3 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Top achievements
Rank 2
answered on 26 Jun 2014, 05:40 PM
Just spit balling...
HtmlInputText txt = your html input control;
txt.Focus();  //set  focus on text control
Manager.Desktop.KeyBoard.KeyDown(System.Windows.Forms.Keys.Control); //hold control key
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.A); //press A to select all text
Manager.Desktop.KeyBoard.KeyUp(System.Windows.Forms.Keys.Control); //let go of control
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Delete); //press delete


Uses the physical keyboard presses instead of simulation.

0
Miguel
Top achievements
Rank 1
answered on 27 Jun 2014, 02:15 PM
Thanks Daniel, that was a simple fix.
0
Daniel
Top achievements
Rank 2
answered on 27 Jun 2014, 02:16 PM
Glad it worked.
Tags
General Discussions
Asked by
Miguel
Top achievements
Rank 1
Answers by
Daniel
Top achievements
Rank 2
Miguel
Top achievements
Rank 1
Share this question
or