Wildcards in WidgetLocator

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

Wildcards in WidgetLocator

Postby a.bitsche » Wed Aug 23, 2006 3:15 am

Is it possible to use the character '*' in a label for a WidgetLocator?

In most texteditors the label of the textwindow is equal to the name of the opened file. If the textfile is dirty a '*' is added at the beginning of the label.

If i try to register a new widget with the label '*test' i get this err-log:
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*test
^
at java.util.regex.Pattern.error(Unknown Source)
at java.util.regex.Pattern.sequence(Unknown Source)
at java.util.regex.Pattern.expr(Unknown Source)
at java.util.regex.Pattern.compile(Unknown Source)
at java.util.regex.Pattern.<init>(Unknown Source)
...


Is it possible to use Wildcards for names or labels in the WidgetLocator?
Last edited by a.bitsche on Thu Sep 14, 2006 11:32 pm, edited 1 time in total.
a.bitsche
 
Posts: 31
Joined: Tue Aug 22, 2006 2:53 am
Location: Austria

Postby Phil Quitslund » Wed Aug 23, 2006 8:10 am

Nice catch!

This is actually a bug that has been fixed (you should be able to use literals and patterns in widget locators) and will available in a fresh beta posted in the next few days.

In the meantime, you can escape the metacharacter using a pattern like this:

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

Postby a.bitsche » Wed Aug 23, 2006 10:59 pm

Tank you for your help!

And how does it look like with wildcards?
Can i use wildcards in a WidgetLocator or is there another
way to get access to an object if the hole name (label) isn't known?
a.bitsche
 
Posts: 31
Joined: Tue Aug 22, 2006 2:53 am
Location: Austria

Postby Phil Quitslund » Thu Aug 24, 2006 5:15 am

We use the standard pattern matcher provided by Java. For more on it, see:

http://java.sun.com/j2se/1.4.2/docs/api ... ttern.html

As for your particular case, a WidgetLocator that uses this pattern:

"(\\*)?test"


for example

Code: Select all
new WidgetLocator("(\\*)?test", Label.class);


should match a Label instance whose text is "test" or "*test".
--
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