TabbedPropertyList [message #27294] |
Thu, 12 March 2009 13:48  |
Eclipse User |
|
|
|
Hi all,
I am using SWTBot to automate the GUI testing for one of our eclipse-based
products. So far it has been working fine. But I am not able to recognize
a TabbedPropertyList. It is similar to the Tabbed Property List that can
be seen in the properties view in eclipse sometimes.
Can anybody help me write some code to identify this widget?
The Property Tabs in my case show up in the interactive editor view in
eclipse.
Thanks,
Bhooshan
|
|
|
|
|
|
|
Re: TabbedPropertyList [message #637482 is a reply to message #28393] |
Fri, 05 November 2010 13:43  |
Eclipse User |
|
|
|
Hi,
I had the same problem today. I didn't know how to test a tabbed
property sheet. I tried your suggestion but did not find the methods and
classes in the latest release (2.0.0.595) so I tried myself to find a way.
I used the "EclipseSpy View" from the SWTBot SDK and I found out that
there is no way to select a tab by name. But I can select a tab by its
index.
This is my solution:
private void selectTab(int index, SWTBotView view) {
Composite parent = (Composite) view.getWidget();
ControlFinder cf = new ControlFinder();
Matcher<Composite> matcher = new
IsInstanceOf<Composite>(Composite.class);
List<Composite> findControls = cf.findControls(parent, matcher,true);
List<Composite> tabs = new ArrayList<Composite>();
for (int i = 0; i < findControls.size(); i++) {
Composite c = findControls.get(i);
String className = SWTUtils.toString(c);
if (className.startsWith("TabbedPropertyList$ListElement")) {
tabs.add(c);
}
}
Composite foundTab = tabs.get(index);
CompositeControl mw = new CompositeControl(foundTab, matcher);
mw.click();
}
private static class CompositeControl extends
AbstractSWTBotControl<Composite> {
public CompositeControl(Composite w, SelfDescribing description)
throws WidgetNotFoundException {
super(w);
}
/**
* Click on the button.
*/
public CompositeControl click() {
log.debug(MessageFormat.format("Clicking on {0}",
SWTUtils.getText(widget))); //$NON-NLS-1$
waitForEnabled();
notify(SWT.MouseEnter);
notify(SWT.MouseMove);
notify(SWT.Activate);
notify(SWT.FocusIn);
notify(SWT.MouseDown);
notify(SWT.MouseUp);
notify(SWT.Selection);
notify(SWT.MouseHover);
notify(SWT.MouseMove);
notify(SWT.MouseExit);
notify(SWT.Deactivate);
notify(SWT.FocusOut);
log.debug(MessageFormat.format("Clicked on {0}",
SWTUtils.getText(widget))); //$NON-NLS-1$
return this;
}
}
The method click() of the class CompositeControl is copied from
SWTBotButton.
I hope this helps. Should I open a bug for a feature request?
With regards,
Udo
Am 18.03.2009 02:42, schrieb Ketan Patel:
> wrong thread is because you are trying to access SWT things outside UI
> thread. You have to execute it in UI thread.
>
> To help with property tabs, here his how you can get started:
>
> //get the view from the bot
> SWTBotView view = bot.view("Properties");
> //if it can be found, then show it. if(null != view){
> view.show();
> }
>
> //get all the tabs in the properties panel //get all
> org.eclipse.ui.internal.views.properties.tabbed.view.TabbedP ropertyList.ListElement
>
> Matcher matcher = widgetOfType(ListElement.class);
> WaitForWidgetInParent waitForWidget = waitForWidget(matcher,
> view.getWidget());
> waitUntilWidgetAppears(waitForWidget);
> //get all found elements.
> List tabs = waitForWidget.getWidgets();
>
|
|
|
Powered by
FUDForum. Page generated in 0.04288 seconds