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?