Backspace key events

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Backspace key events

Postby iduman » Mon Mar 30, 2009 12:59 am

Hello

With Window Tester 3.7.0, while recording I noticed that Backspace key events in JTextField widget are captured but no source code is produced for these events. Because of this, when I run the produced test code I didn't get the expected results.

If there is something in the JTextField when you start recording and if you press Backspace to clean the JTextField, the text field is cleaned and you enter new value as an input. But since no source code is produced for Backspace key, you end up with a wrong result.

For example; I enter "a" then change the focus, then come back to the same text field then I try to enter "45" by pressing Backspace to clean the text field. When I replay the test code "a45" is displayed in the text field and test is failed.

Thanks
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Backspace key events

Postby 3061 » Mon Mar 30, 2009 4:23 am

Here's a workaround:

Use CTRL + A to select all the text in a field. When you start typing, it automatically deletes the previous text and inserts the new one.

I made this to enter text in Wizards:

Code: Select all
/**
* Enters text in a single line, plain text field. Use this for wizards.
*
* @param label The label closest to the text box. Example: "Name"
* @param content The text that shall be entered. Note that the Text field
* is cleared (previous text erased) beforehand.
* @throws WidgetSearchException
*/
protected void enterTextInTextBox(String label, String content) throws WidgetSearchException
{
   ui.click(new LabeledLocator(Text.class, label));
   ui.keyClick(SWT.CTRL, 'a');
   ui.enterText(content);
}
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Backspace key events

Postby iduman » Mon Mar 30, 2009 4:42 am

I am using Swing. I would like the Window Tester recorder to produce the code automatically instead of writing the code manually. Is there a way of doing this?
iduman
 
Posts: 21
Joined: Tue Nov 18, 2008 5:46 am

Re: Backspace key events

Postby 3061 » Mon Mar 30, 2009 5:21 am

iduman wrote:I am using Swing. I would like the Window Tester recorder to produce the code automatically instead of writing the code manually. Is there a way of doing this?


Just tried it out here... The recorder apparently does not record when you click inside a text box. It waits until you're done editing the text and then generates a enterText-Command with the complete String. Else the recorder would output something like:
Code: Select all
ui.keyClick("h");
ui.keyClick("e");
ui.keyClick("l");
ui.keyClick("l");
ui.keyClick("o");
ui.keyClick(" ");
ui.keyClick("w");
ui.keyClick("o");
ui.keyClick("r");
ui.keyClick("l");
ui.keyClick("d");
ui.keyClick("!");


Which would make manual editing really painful...
It would be nice to have a preference in the WindowTester/CodeGen preferences where you can choose between String recording (ui.enterText) or keystroke recording (ui.keyclick).
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: Backspace key events

Postby Phil Quitslund » Mon Mar 30, 2009 11:59 am

We don't record backspace events but in the general case, backspaces are usually mistakes. (Of the I meant to type "Fred" but typed "Freed" instead variety.) If this is important to you go ahead and send a feature request to wintest-support@instantiations.com where we will review and track the request.

Thanks for the valuable feedback!


-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest