Locating the Label with Regex/wild card

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

Locating the Label with Regex/wild card

Postby manikanti » Tue Jun 16, 2009 9:06 pm

Hi,

In the view, there are multiple labels and the content of the label is dynamic (like search results "2 files found"). Is it possible locate the label by giving partial text "files found" or someother means without providing full text of the label (as label content is dynamic)? Once, label is located, want to retrieve the label text.

ui.click(new SWTWidgetLocator(Label.class, "2 files found")); // works fine, but full text is provided, and 2 is not constant.

Following ways already tried and not working...
System.out.println("<<----->>>>"+new LabeledLabelLocator(".*"));
System.out.println("----->>>>"+new SWTWidgetLocator(Label.class, ".* files found").getNameOrLabel());
System.out.println("----->>>>"+new SWTWidgetLocator(Label.class, ".\\* files found").getNameOrLabel());
System.out.println("<<----->>>>"+new SWTWidgetLocator(Label.class, ".*\\ files found").getNameOrLabel());
System.out.println("<<----->>>>"+new LabeledLabelLocator(".*"));

IWidgetLocator[] etab=ui.findAll(new SWTWidgetLocator(Label.class, "2 Reviews Found").getParentInfo());
for (int i=0;i<etab.length;i++) {
//System.out.println(" i ="+i+"text is:"+((SWTWidgetLocator)etab[i]).getNameOrLabel());
}


String getText(final Label widget) {
final String text[] = new String[1];
Display.getDefault().syncExec(new Runnable() {
public void run() {
text[0] = widget.getText();
}
});
return text[0];
}


Any idea?
manikanti
 
Posts: 12
Joined: Tue Jun 16, 2009 8:06 pm

Re: Locating the Label with Regex/wild card

Postby Phil Quitslund » Wed Jun 17, 2009 7:26 pm

Hey there. It looks like you may have but to be sure, did you try this?:
Code: Select all
IWidgetLocator[] labels = ui.findAll(new SWTWidgetLocator(Label.class, ".* files found"));

If this did not do the trick, please file a ticket with support (wintest-support@instantiations.com) since this should really do it.

Thanks!
--
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