HasText on Swing

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

HasText on Swing

Postby jcarre » Tue Mar 11, 2008 1:26 am

Hello,

How can I perform an HasText condition on a Swing component ?
I use a JTextComponentLocator which don't implements HasText interface.

Thx
jcarre
 
Posts: 2
Joined: Tue Mar 11, 2008 1:19 am

Re: HasText on Swing

Postby keertip » Tue Mar 11, 2008 10:29 am

Hi,

We are in the process of implementing the HasText condition for the Swing locators. For now, to verify the text in a textfield, you can do the following:

Code: Select all
      IWidgetReference wref = (IWidgetReference)ui.click(new JTextComponentLocator(JTextField.class));
      JTextField textField = (JTextField) wref.getWidget();
      ui.enterText("hello");
      assertEquals("hello",textField.getText());



The same technique can be used for any Component that contains text. Hope this helps! Will inform you once we have the HasText implemented.

-keerti
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest