Add HasText Assertion

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

Add HasText Assertion

Postby EDWARD BOLLES » Tue Jul 01, 2008 10:35 am


I would like to test a string in a field.

For example, I have this code in my script to click in the field and get it in focus: XYLocator(new LabeledTextLocator("Process Name:", new ViewLocator("org.eclipse.ui.views.PropertySheet")), 96,8)); // click on text field

assert_2(); // position marker


I tried the following but I got an error:

ui.assertThat(new HasTextCondition(new XYLocator(new LabeledTextLocator("Process Name:", new ViewLocator("org.eclipse.ui.views.PropertySheet")), 96,8), "loopProcess")); // HasTextCondition cannot be resolved to a type

Any tips would be greatly appreciated.

Posts: 7
Joined: Tue Jun 17, 2008 9:02 am

Re: Add HasText Assertion

Postby Phil Quitslund » Tue Jul 01, 2008 1:06 pm

The trouble here is that the XYLocator does not support the hasText protocol. Since you don't actually need the XY for the text, you can ignore it. Try the following (and note the use of the hasText(..) convenience Condition factory method on the LabeledTextLocator):

Code: Select all
ui.assertThat(new LabeledTextLocator("Process Name:", new ViewLocator("org.eclipse.ui.views.PropertySheet")).hasText("loopProcess"));

Hope this works for you. Let us know either way!
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
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