org.eclipse.swtbot.eclipse.finder
Class SWTWorkbenchBot

java.lang.Object
  extended by org.eclipse.swtbot.swt.finder.SWTBot
      extended by org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
Direct Known Subclasses:
SWTEclipseBot, SWTGefBot

public class SWTWorkbenchBot
extends SWTBot

SWTWorkbenchBot is a SWTBot with capabilities for testing Eclipse workbench items like views, editors and perspectives

Version:
$Id$
Author:
Ralf Ebert www.ralfebert.de (bug 271630)

Field Summary
static long DEFAULT_POLL_DELAY
          Deprecated. 
protected  Display display
          The display on which the bot operates on.
protected  Finder finder
          The finder used by the bot to find controls.
 
Constructor Summary
SWTWorkbenchBot()
          Constructs a workbench bot
 
Method Summary
 SWTBotEditor activeEditor()
          Returns the active workbench editor part
 SWTBotPerspective activePerspective()
           
 SWTBotShell activeShell()
          Gets the current active shell.
 SWTBotView activeView()
          Returns the active workbench view part
 boolean captureScreenshot(String fileName)
          Captures a screenshot to the given file name.
 void closeAllEditors()
           
 void closeAllShells()
           
 SWTBotPerspective defaultPerspective()
          Returns the default perspective as defined in the WorkbenchAdvisor of the application.
 SWTBotEditor editor(Matcher<IEditorReference> matcher)
          Waits for a editor matching the given matcher to appear in the active workbench page and returns it
 SWTBotEditor editorById(String id)
          Shortcut for editor(withPartId(id))
 SWTBotEditor editorByTitle(String fileName)
          Shortcut for editor(withPartName(title))
 List<? extends SWTBotEditor> editors()
           
 List<SWTBotEditor> editors(Matcher<?> matcher)
           
 Display getDisplay()
          Gets the display
 Finder getFinder()
           
 Control getFocusedWidget()
          Returns the control which currently has keyboard focus, or null if keyboard events are not currently going to any of the controls built by the currently running application.
 SWTBotMenu menu(String text)
           
 SWTBotMenu menu(String text, int index)
           
 SWTBotMenu menu(SWTBotShell shell, Matcher<MenuItem> matcher, int index)
           
 SWTBotMenu menuWithId(String value)
           
 SWTBotMenu menuWithId(String value, int index)
           
 SWTBotMenu menuWithId(String key, String value)
           
 SWTBotMenu menuWithId(String key, String value, int index)
           
 SWTBotMultiPageEditor multipageEditor(Matcher<IEditorReference> matcher)
          Waits for a multipage editor matching the given matcher to appear in the active workbench page and returns it
 SWTBotMultiPageEditor multipageEditorById(String id)
          Shortcut for multipageEditor(withPartId(id))
 SWTBotMultiPageEditor multipageEditorByTitle(String fileName)
          Shortcut for multipageEditor(withPartName(title))
 List<? extends SWTBotMultiPageEditor> multipageEditors()
           
 List<SWTBotMultiPageEditor> multipageEditors(Matcher<?> matcher)
           
<T> T
performWithTimeout(Result<T> runnable, long timeout)
          Performs an operation with a timeout and return a result.
 void performWithTimeout(VoidResult runnable, long timeout)
           
 SWTBotPerspective perspective(Matcher<?> matcher)
          Returns the perspective matching the given matcher
 SWTBotPerspective perspectiveById(String id)
          Shortcut for perspective(perspectiveById(label))
 SWTBotPerspective perspectiveByLabel(String label)
          Shortcut for perspective(withPerspectiveLabel(label))
 List<SWTBotPerspective> perspectives()
           
 List<SWTBotPerspective> perspectives(Matcher<?> matcher)
           
 SWTBotPerspective resetActivePerspective()
           
 void resetWorkbench()
          Does a best effort to reset the workbench.
 void saveAllEditors()
           
 SWTBotShell shell(String text)
           
 SWTBotShell shell(String text, int index)
           
 SWTBotShell shell(String text, Shell parent)
           
 SWTBotShell shell(String text, Shell parent, int index)
           
 SWTBotShell[] shells()
          Gets the list of shells found in the display.
 List<Shell> shells(String text)
           
 List<Shell> shells(String text, Shell parent)
           
 SWTBotShell shellWithId(String value)
           
 SWTBotShell shellWithId(String value, int index)
           
 SWTBotShell shellWithId(String key, String value)
           
 SWTBotShell shellWithId(String key, String value, int index)
           
 void sleep(long millis)
          Sleeps for the given number of milliseconds.
protected  Tray systemTray()
           
 SWTBotTrayItem trayItem()
           
 SWTBotTrayItem trayItem(int index)
           
 List<SWTBotTrayItem> trayItems()
           
 List<SWTBotTrayItem> trayItems(Matcher<?> matcher)
           
 SWTBotTrayItem trayItemWithTooltip(String tooltip)
           
 SWTBotTrayItem trayItemWithTooltip(String tooltip, int index)
           
 SWTBotView view(Matcher<IViewReference> matcher)
          Waits for a view matching the given matcher to appear in the active workbench page and returns it
 SWTBotView viewById(String id)
          Shortcut for view(withPartId(id))
 SWTBotView viewByTitle(String title)
          Shortcut for view(withPartName(title))
 List<SWTBotView> views()
           
 List<SWTBotView> views(Matcher<?> matcher)
          Returns all views which are opened currently (no waiting!) which match the given matcher
 void waitUntil(ICondition condition)
          Waits until a specified condition evaluates to true.
 void waitUntil(ICondition condition, long timeout)
          Waits until the timeout is reached or the condition is met.
 void waitUntil(ICondition condition, long timeout, long interval)
          Waits until the condition has been meet, or the timeout is reached.
 void waitUntilWidgetAppears(ICondition waitForWidget)
           
 void waitWhile(ICondition condition)
          Waits while the condition is true.
 void waitWhile(ICondition condition, long timeout)
          Waits while the condition is true, until the timeout is reached.
 void waitWhile(ICondition condition, long timeout, long interval)
          Waits while the condition is true, until the timeout is reached.
<T extends Widget>
T
widget(Matcher<T> matcher)
           
<T extends Widget>
T
widget(Matcher<T> matcher, int index)
           
<T extends Widget>
T
widget(Matcher<T> matcher, Widget parentWidget)
           
<T extends Widget>
T
widget(Matcher<T> matcher, Widget parentWidget, int index)
           
<T extends Widget>
List<? extends T>
widgets(Matcher<T> matcher)
           
<T extends Widget>
List<? extends T>
widgets(Matcher<T> matcher, Widget parentWidget)
           
 
Methods inherited from class org.eclipse.swtbot.swt.finder.SWTBot
browser, browser, browserInGroup, browserInGroup, browserWithId, browserWithId, browserWithId, browserWithId, browserWithLabel, browserWithLabel, browserWithLabelInGroup, browserWithLabelInGroup, button, button, button, button, buttonInGroup, buttonInGroup, buttonInGroup, buttonInGroup, buttonWithId, buttonWithId, buttonWithId, buttonWithId, buttonWithLabel, buttonWithLabel, buttonWithLabelInGroup, buttonWithLabelInGroup, buttonWithTooltip, buttonWithTooltip, buttonWithTooltipInGroup, buttonWithTooltipInGroup, ccomboBox, ccomboBox, ccomboBox, ccomboBox, ccomboBoxInGroup, ccomboBoxInGroup, ccomboBoxInGroup, ccomboBoxInGroup, ccomboBoxWithId, ccomboBoxWithId, ccomboBoxWithId, ccomboBoxWithId, ccomboBoxWithLabel, ccomboBoxWithLabel, ccomboBoxWithLabelInGroup, ccomboBoxWithLabelInGroup, checkBox, checkBox, checkBox, checkBox, checkBoxInGroup, checkBoxInGroup, checkBoxInGroup, checkBoxInGroup, checkBoxWithId, checkBoxWithId, checkBoxWithId, checkBoxWithId, checkBoxWithLabel, checkBoxWithLabel, checkBoxWithLabelInGroup, checkBoxWithLabelInGroup, checkBoxWithTooltip, checkBoxWithTooltip, checkBoxWithTooltipInGroup, checkBoxWithTooltipInGroup, clabel, clabel, clabel, clabel, clabelInGroup, clabelInGroup, clabelInGroup, clabelInGroup, clabelWithId, clabelWithId, clabelWithId, clabelWithId, comboBox, comboBox, comboBox, comboBox, comboBoxInGroup, comboBoxInGroup, comboBoxInGroup, comboBoxInGroup, comboBoxWithId, comboBoxWithId, comboBoxWithId, comboBoxWithId, comboBoxWithLabel, comboBoxWithLabel, comboBoxWithLabelInGroup, comboBoxWithLabelInGroup, cTabItem, cTabItem, cTabItem, cTabItem, cTabItemInGroup, cTabItemInGroup, cTabItemInGroup, cTabItemInGroup, cTabItemWithId, cTabItemWithId, cTabItemWithId, cTabItemWithId, dateTime, dateTime, dateTimeInGroup, dateTimeInGroup, dateTimeWithId, dateTimeWithId, dateTimeWithId, dateTimeWithId, dateTimeWithLabel, dateTimeWithLabel, dateTimeWithLabelInGroup, dateTimeWithLabelInGroup, expandBar, expandBar, expandBarInGroup, expandBarInGroup, expandBarWithId, expandBarWithId, expandBarWithId, expandBarWithId, expandBarWithLabel, expandBarWithLabel, expandBarWithLabelInGroup, expandBarWithLabelInGroup, label, label, label, label, labelInGroup, labelInGroup, labelInGroup, labelInGroup, labelWithId, labelWithId, labelWithId, labelWithId, link, link, link, link, linkInGroup, linkInGroup, linkInGroup, linkInGroup, linkWithId, linkWithId, linkWithId, linkWithId, list, list, listInGroup, listInGroup, listWithId, listWithId, listWithId, listWithId, listWithLabel, listWithLabel, listWithLabelInGroup, listWithLabelInGroup, radio, radio, radio, radio, radioInGroup, radioInGroup, radioInGroup, radioInGroup, radioWithId, radioWithId, radioWithId, radioWithId, radioWithLabel, radioWithLabel, radioWithLabelInGroup, radioWithLabelInGroup, radioWithTooltip, radioWithTooltip, radioWithTooltipInGroup, radioWithTooltipInGroup, scale, scale, scale, scale, scaleInGroup, scaleInGroup, scaleInGroup, scaleInGroup, scaleWithId, scaleWithId, scaleWithId, scaleWithId, scaleWithLabel, scaleWithLabel, scaleWithLabelInGroup, scaleWithLabelInGroup, scaleWithTooltip, scaleWithTooltip, scaleWithTooltipInGroup, scaleWithTooltipInGroup, slider, slider, slider, slider, sliderInGroup, sliderInGroup, sliderInGroup, sliderInGroup, sliderWithId, sliderWithId, sliderWithId, sliderWithId, sliderWithLabel, sliderWithLabel, sliderWithLabelInGroup, sliderWithLabelInGroup, sliderWithTooltip, sliderWithTooltip, sliderWithTooltipInGroup, sliderWithTooltipInGroup, spinner, spinner, spinner, spinner, spinnerInGroup, spinnerInGroup, spinnerInGroup, spinnerInGroup, spinnerWithId, spinnerWithId, spinnerWithId, spinnerWithId, spinnerWithLabel, spinnerWithLabel, spinnerWithLabelInGroup, spinnerWithLabelInGroup, spinnerWithTooltip, spinnerWithTooltip, spinnerWithTooltipInGroup, spinnerWithTooltipInGroup, styledText, styledText, styledText, styledText, styledTextInGroup, styledTextInGroup, styledTextInGroup, styledTextInGroup, styledTextWithId, styledTextWithId, styledTextWithId, styledTextWithId, styledTextWithLabel, styledTextWithLabel, styledTextWithLabelInGroup, styledTextWithLabelInGroup, tabItem, tabItem, tabItem, tabItem, tabItemInGroup, tabItemInGroup, tabItemInGroup, tabItemInGroup, tabItemWithId, tabItemWithId, tabItemWithId, tabItemWithId, table, table, tableInGroup, tableInGroup, tableWithId, tableWithId, tableWithId, tableWithId, tableWithLabel, tableWithLabel, tableWithLabelInGroup, tableWithLabelInGroup, text, text, text, text, textInGroup, textInGroup, textInGroup, textInGroup, textWithId, textWithId, textWithId, textWithId, textWithLabel, textWithLabel, textWithLabelInGroup, textWithLabelInGroup, textWithMessage, textWithMessage, textWithTooltip, textWithTooltip, textWithTooltipInGroup, textWithTooltipInGroup, toggleButton, toggleButton, toggleButton, toggleButton, toggleButtonInGroup, toggleButtonInGroup, toggleButtonInGroup, toggleButtonInGroup, toggleButtonWithId, toggleButtonWithId, toggleButtonWithId, toggleButtonWithId, toggleButtonWithLabel, toggleButtonWithLabel, toggleButtonWithLabelInGroup, toggleButtonWithLabelInGroup, toggleButtonWithTooltip, toggleButtonWithTooltip, toggleButtonWithTooltipInGroup, toggleButtonWithTooltipInGroup, toolbarButton, toolbarButton, toolbarButton, toolbarButton, toolbarButtonInGroup, toolbarButtonInGroup, toolbarButtonInGroup, toolbarButtonInGroup, toolbarButtonWithId, toolbarButtonWithId, toolbarButtonWithId, toolbarButtonWithId, toolbarButtonWithTooltip, toolbarButtonWithTooltip, toolbarButtonWithTooltipInGroup, toolbarButtonWithTooltipInGroup, toolbarDropDownButton, toolbarDropDownButton, toolbarDropDownButton, toolbarDropDownButton, toolbarDropDownButtonInGroup, toolbarDropDownButtonInGroup, toolbarDropDownButtonInGroup, toolbarDropDownButtonInGroup, toolbarDropDownButtonWithId, toolbarDropDownButtonWithId, toolbarDropDownButtonWithId, toolbarDropDownButtonWithId, toolbarDropDownButtonWithTooltip, toolbarDropDownButtonWithTooltip, toolbarDropDownButtonWithTooltipInGroup, toolbarDropDownButtonWithTooltipInGroup, toolbarRadioButton, toolbarRadioButton, toolbarRadioButton, toolbarRadioButton, toolbarRadioButtonInGroup, toolbarRadioButtonInGroup, toolbarRadioButtonInGroup, toolbarRadioButtonInGroup, toolbarRadioButtonWithId, toolbarRadioButtonWithId, toolbarRadioButtonWithId, toolbarRadioButtonWithId, toolbarRadioButtonWithTooltip, toolbarRadioButtonWithTooltip, toolbarRadioButtonWithTooltipInGroup, toolbarRadioButtonWithTooltipInGroup, toolbarToggleButton, toolbarToggleButton, toolbarToggleButton, toolbarToggleButton, toolbarToggleButtonInGroup, toolbarToggleButtonInGroup, toolbarToggleButtonInGroup, toolbarToggleButtonInGroup, toolbarToggleButtonWithId, toolbarToggleButtonWithId, toolbarToggleButtonWithId, toolbarToggleButtonWithId, toolbarToggleButtonWithTooltip, toolbarToggleButtonWithTooltip, toolbarToggleButtonWithTooltipInGroup, toolbarToggleButtonWithTooltipInGroup, tree, tree, treeInGroup, treeInGroup, treeWithId, treeWithId, treeWithId, treeWithId, treeWithLabel, treeWithLabel, treeWithLabelInGroup, treeWithLabelInGroup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POLL_DELAY

@Deprecated
public static final long DEFAULT_POLL_DELAY
Deprecated. 
the delay between successive polling while waiting for a condition to be true. Use SWTBotPreferences#DEFAULT_POLL_DELAY


display

protected final Display display
The display on which the bot operates on.


finder

protected final Finder finder
The finder used by the bot to find controls.

Constructor Detail

SWTWorkbenchBot

public SWTWorkbenchBot()
Constructs a workbench bot

Method Detail

perspective

public SWTBotPerspective perspective(Matcher<?> matcher)
Returns the perspective matching the given matcher

Parameters:
matcher - the matcher used to find the perspective
Returns:
a perspective matching the matcher
Throws:
WidgetNotFoundException - if the perspective is not found

perspectiveByLabel

public SWTBotPerspective perspectiveByLabel(String label)
Shortcut for perspective(withPerspectiveLabel(label))

Parameters:
label - the "human readable" label for the perspective
Returns:
a perspective with the specified label
See Also:
perspective(Matcher), WidgetMatcherFactory.withPerspectiveLabel(Matcher)

perspectiveById

public SWTBotPerspective perspectiveById(String id)
Shortcut for perspective(perspectiveById(label))

Parameters:
id - the perspective id
Returns:
a perspective with the specified label
See Also:
perspective(Matcher), WidgetMatcherFactory.withPerspectiveId(Matcher)

perspectives

public List<SWTBotPerspective> perspectives(Matcher<?> matcher)
Parameters:
matcher - Matcher for IPerspectiveDescriptor
Returns:
all available matching perspectives

perspectives

public List<SWTBotPerspective> perspectives()
Returns:
all available perspectives

view

public SWTBotView view(Matcher<IViewReference> matcher)
Waits for a view matching the given matcher to appear in the active workbench page and returns it

Parameters:
matcher - the matcher used to match views
Returns:
views that match the matcher
Throws:
WidgetNotFoundException - if the view is not found

viewByTitle

public SWTBotView viewByTitle(String title)
Shortcut for view(withPartName(title))

Parameters:
title - the "human readable" title
Returns:
the view with the specified title
See Also:
WidgetMatcherFactory.withPartName(Matcher)

viewById

public SWTBotView viewById(String id)
Shortcut for view(withPartId(id))

Parameters:
id - the view id
Returns:
the view with the specified id
See Also:
WidgetMatcherFactory.withPartId(String)

views

public List<SWTBotView> views(Matcher<?> matcher)
Returns all views which are opened currently (no waiting!) which match the given matcher

Parameters:
matcher - the matcher used to find views
Returns:
the list of all matching views

views

public List<SWTBotView> views()
Returns:
all views which are opened currently

activeView

public SWTBotView activeView()
Returns the active workbench view part

Returns:
the active view, if any
Throws:
WidgetNotFoundException - if there is no active view

editor

public SWTBotEditor editor(Matcher<IEditorReference> matcher)
Waits for a editor matching the given matcher to appear in the active workbench page and returns it

Parameters:
matcher - the matcher used to find the editor
Returns:
an editor that matches the matcher
Throws:
WidgetNotFoundException - if the editor is not found

editors

public List<SWTBotEditor> editors(Matcher<?> matcher)
Parameters:
matcher - the matcher used to find all editors
Returns:
all editors which are opened currently (no waiting!) which match the given matcher

editors

public List<? extends SWTBotEditor> editors()
Returns:
all editors which are opened currently

editorByTitle

public SWTBotEditor editorByTitle(String fileName)
Shortcut for editor(withPartName(title))

Parameters:
fileName - the the filename on the editor tab
Returns:
the editor with the specified title
See Also:
editor(Matcher)

editorById

public SWTBotEditor editorById(String id)
Shortcut for editor(withPartId(id))

Parameters:
id - the the id on the editor tab
Returns:
the editor with the specified title
See Also:
editor(Matcher)

activeEditor

public SWTBotEditor activeEditor()
Returns the active workbench editor part

Returns:
the active editor, if any
Throws:
WidgetNotFoundException - if there is no active view

multipageEditor

public SWTBotMultiPageEditor multipageEditor(Matcher<IEditorReference> matcher)
Waits for a multipage editor matching the given matcher to appear in the active workbench page and returns it

Parameters:
matcher - the matcher used to find the editor
Returns:
an editor that matches the matcher
Throws:
WidgetNotFoundException - if the editor is not found

multipageEditors

public List<SWTBotMultiPageEditor> multipageEditors(Matcher<?> matcher)
Parameters:
matcher - the matcher used to find all editors
Returns:
all multipage editors which are opened currently (no waiting!) which match the given matcher

multipageEditors

public List<? extends SWTBotMultiPageEditor> multipageEditors()
Returns:
all editors which are opened currently

multipageEditorByTitle

public SWTBotMultiPageEditor multipageEditorByTitle(String fileName)
Shortcut for multipageEditor(withPartName(title))

Parameters:
fileName - the the filename on the editor tab
Returns:
the editor with the specified title
See Also:
editor(Matcher)

multipageEditorById

public SWTBotMultiPageEditor multipageEditorById(String id)
Shortcut for multipageEditor(withPartId(id))

Parameters:
id - the the id on the editor tab
Returns:
the editor with the specified title
See Also:
editor(Matcher)

activePerspective

public SWTBotPerspective activePerspective()
Returns:
the active perspective in the active workbench page

resetWorkbench

public void resetWorkbench()
Does a best effort to reset the workbench. This method attempts to:

defaultPerspective

public SWTBotPerspective defaultPerspective()
Returns the default perspective as defined in the WorkbenchAdvisor of the application.


closeAllEditors

public void closeAllEditors()

saveAllEditors

public void saveAllEditors()

resetActivePerspective

public SWTBotPerspective resetActivePerspective()

closeAllShells

public void closeAllShells()

shell

public SWTBotShell shell(String text)
Parameters:
text - the text on the shell.
Returns:
a wrapper around a @{link Shell} with the specified text.

shell

public SWTBotShell shell(String text,
                         int index)
Parameters:
text - the text on the shell.
index - the index of the shell, in case there are multiple shells with the same text.
Returns:
a wrapper around a Shell with the specified index.

shells

public List<Shell> shells(String text)
Parameters:
text - the text on the shell.
Returns:
a wrapper around a Shell with the specified index.

shell

public SWTBotShell shell(String text,
                         Shell parent)
Parameters:
text - the text on the shell.
parent - the parent under which a shell will be found.
Returns:
a wrapper around a @{link Shell} with the specified text.

shell

public SWTBotShell shell(String text,
                         Shell parent,
                         int index)
Parameters:
text - the text on the shell.
parent - the parent under which a shell will be found.
index - the index of the shell, in case there are multiple shells with the same text.
Returns:
a wrapper around a Shell with the specified index.

shells

public List<Shell> shells(String text,
                          Shell parent)
Parameters:
text - the text on the shell.
parent - the parent under which a shell will be found.
Returns:
a List of Shell which matched.

shellWithId

public SWTBotShell shellWithId(String value)
Parameters:
value - the value of the id
Returns:
a wrapper around a @{link Shell} with the specified value pair for its id.
Since:
2.0

shellWithId

public SWTBotShell shellWithId(String key,
                               String value)
Parameters:
key - the key of the id
value - the value of the id
Returns:
a wrapper around a @{link Shell} with the specified key/value pair for its id.

shellWithId

public SWTBotShell shellWithId(String value,
                               int index)
Parameters:
value - the value of the id
index - the index of the shell, in case there are multiple shells with the same text.
Returns:
a wrapper around a @{link Shell} with the specified value for its id.
Since:
2.0

shellWithId

public SWTBotShell shellWithId(String key,
                               String value,
                               int index)
Parameters:
key - the key of the id
value - the value of the id
index - the index of the shell, in case there are multiple shells with the same text.
Returns:
a wrapper around a @{link Shell} with the specified key/value pair for its id.

menu

public SWTBotMenu menu(String text)
Parameters:
text - the text on the menu.
Returns:
a menu item that matches the specified text.

menu

public SWTBotMenu menu(String text,
                       int index)
Parameters:
text - the text on the menu.
index - the index of the menu, in case there are multiple menus with the same text.
Returns:
a menu item that matches the specified text.

menuWithId

public SWTBotMenu menuWithId(String value)
Parameters:
value - the value of the id.
Returns:
a wrapper around a @{link Menu} with the specified key/value pair for its id.

menuWithId

public SWTBotMenu menuWithId(String value,
                             int index)
Parameters:
value - the value of the id.
index - the index of the menu item, in case there are multiple shells with the same text.
Returns:
a wrapper around a @{link Menu} with the specified key/value pair for its id.

menuWithId

public SWTBotMenu menuWithId(String key,
                             String value)
Parameters:
key - the key of the id.
value - the value of the id.
Returns:
a wrapper around a @{link Menu} with the specified key/value pair for its id.

menuWithId

public SWTBotMenu menuWithId(String key,
                             String value,
                             int index)
Parameters:
key - the key of the id.
value - the value of the id.
index - the index of the menu item, in case there are multiple shells with the same text.
Returns:
a wrapper around a @{link Menu} with the specified key/value pair for its id.

menu

public SWTBotMenu menu(SWTBotShell shell,
                       Matcher<MenuItem> matcher,
                       int index)
Parameters:
shell - the shell to search for the menu.
matcher - the matcher used to find the menu.
index - the index of the menu, in case there are multiple menus with the same text.
Returns:
a menu item that matches the specified text.

widgets

public <T extends Widget> List<? extends T> widgets(Matcher<T> matcher,
                                                    Widget parentWidget)
Parameters:
matcher - the matcher used to match widgets.
parentWidget - the parent widget to search for a given widget.
Returns:
a list of widgets that match the matcher.

widgets

public <T extends Widget> List<? extends T> widgets(Matcher<T> matcher)
Parameters:
matcher - the matcher used to match widgets.
Returns:
a list of widgets in the active shell that match the matcher.

widget

public <T extends Widget> T widget(Matcher<T> matcher,
                                   Widget parentWidget)
Parameters:
matcher - the matcher used to match widgets.
parentWidget - the parent widget to search for a given widget.
Returns:
the first widget that matchs the matcher.

widget

public <T extends Widget> T widget(Matcher<T> matcher,
                                   Widget parentWidget,
                                   int index)
Parameters:
matcher - the matcher used to match widgets.
parentWidget - the parent widget to search for a given widget.
index - the index of the widget, incase the matcher finds multiple widgets
Returns:
the first widget that matchs the matcher.

widget

public <T extends Widget> T widget(Matcher<T> matcher,
                                   int index)
Parameters:
matcher - the matcher used to match widgets.
index - the index of the widget in case there are multiple widgets.
Returns:
the index'th widget matching the matcher.

widget

public <T extends Widget> T widget(Matcher<T> matcher)
Parameters:
matcher - the matcher used to match widgets.
Returns:
the index'th widget matching the matcher.

shells

public SWTBotShell[] shells()
Gets the list of shells found in the display.

Returns:
all the shells in the display.

activeShell

public SWTBotShell activeShell()
                        throws WidgetNotFoundException
Gets the current active shell.

Returns:
the current active shell
Throws:
WidgetNotFoundException - if the widget is not found.

waitUntilWidgetAppears

public void waitUntilWidgetAppears(ICondition waitForWidget)

waitUntil

public void waitUntil(ICondition condition)
               throws TimeoutException
Waits until a specified condition evaluates to true.

Parameters:
condition - the ICondition to be evaluated.
Throws:
TimeoutException - if the condition does not evaluate to true after SWTBotPreferences.TIMEOUT milliseconds.
Since:
1.2

waitUntil

public void waitUntil(ICondition condition,
                      long timeout)
               throws TimeoutException
Waits until the timeout is reached or the condition is met.

Parameters:
condition - the condition to be evaluated.
timeout - the timeout.
Throws:
TimeoutException - if the condition does not evaluate to true after timeout milliseconds.
Since:
1.2

waitUntil

public void waitUntil(ICondition condition,
                      long timeout,
                      long interval)
               throws TimeoutException
Waits until the condition has been meet, or the timeout is reached. The interval is the delay between evaluating the condition after it has failed.

Parameters:
condition - the condition to be evaluated.
timeout - the timeout.
interval - The delay time.
Throws:
TimeoutException - if the condition does not evaluate to true after timeout milliseconds.

waitWhile

public void waitWhile(ICondition condition)
               throws TimeoutException
Waits while the condition is true.

Parameters:
condition - the ICondition to be evaluated.
Throws:
TimeoutException - if the condition does not evaluate to false after SWTBotPreferences.TIMEOUT milliseconds.
Since:
2.0

waitWhile

public void waitWhile(ICondition condition,
                      long timeout)
               throws TimeoutException
Waits while the condition is true, until the timeout is reached.

Parameters:
condition - the condition to be evaluated.
timeout - the timeout.
Throws:
TimeoutException - if the condition does not evaluate to false after timeout milliseconds.
Since:
2.0

waitWhile

public void waitWhile(ICondition condition,
                      long timeout,
                      long interval)
               throws TimeoutException
Waits while the condition is true, until the timeout is reached. The interval is the delay between evaluating the condition after it has succeed.

Parameters:
condition - the condition to be evaluated.
timeout - the timeout.
interval - The delay time.
Throws:
TimeoutException - if the condition does not evaluate to false after timeout milliseconds.
Since:
2.0

sleep

public void sleep(long millis)
Sleeps for the given number of milliseconds.

Parameters:
millis - the time in milliseconds for which to sleep.

getDisplay

public Display getDisplay()
Gets the display

Returns:
the display
Since:
1.0

captureScreenshot

public boolean captureScreenshot(String fileName)
Captures a screenshot to the given file name.

Parameters:
fileName - the filename to save screenshot to.
Returns:
true if the screenshot was created and saved, false otherwise.
Since:
1.1
See Also:
SWTUtils.captureScreenshot(String)

getFinder

public Finder getFinder()
Returns:
the finder

getFocusedWidget

public Control getFocusedWidget()
Returns the control which currently has keyboard focus, or null if keyboard events are not currently going to any of the controls built by the currently running application.

Returns:
the control which currently has focus, or null
See Also:
Display.getFocusControl()

trayItem

public SWTBotTrayItem trayItem()
Returns:
the first SWTBotTrayItem

trayItem

public SWTBotTrayItem trayItem(int index)
Parameters:
index - he index of the tray item.
Returns:
a SWTBotTrayItem at specified index

trayItemWithTooltip

public SWTBotTrayItem trayItemWithTooltip(String tooltip)
Parameters:
tooltip - the tooltip on the tray item.
Returns:
the first SWTBotTrayItem with the specified tooltip.

trayItemWithTooltip

public SWTBotTrayItem trayItemWithTooltip(String tooltip,
                                          int index)
Parameters:
tooltip - the tooltip on the tray item.
index - the index of the tray item.
Returns:
a SWTBotTrayItem with the specified tooltip.

trayItems

public List<SWTBotTrayItem> trayItems()
Returns:
List of all tray items in the system tray.

trayItems

public List<SWTBotTrayItem> trayItems(Matcher<?> matcher)
Parameters:
matcher - the matcher used to match tray item
Returns:
List of SWTBotTrayItem matching the matcher.

systemTray

protected Tray systemTray()
Returns:
The single instance of the system tray

performWithTimeout

public <T> T performWithTimeout(Result<T> runnable,
                                long timeout)
Performs an operation with a timeout and return a result.

This is a convenience api for performing a particular operation with a different timeout:

 long timeout = ...;
 long old = SWTBotPreferences.TIMEOUT;
 SWTBotPreferences.TIMEOUT = timeout;
 try {
        // do something that takes very long
        return aNumber;
 } finally {
        SWTBotPreferences.TIMEOUT = old;
 }
 

The above can now be written as:

 performWithTimeout(new Result() {
        public Integer run() {
                // do something that takes very long
        }
 }, timeout);

Parameters:
runnable - the runnable to execute.
timeout - the timeout for performing the operation.
Returns:
the result of executing the runnable.

performWithTimeout

public void performWithTimeout(VoidResult runnable,
                               long timeout)
Parameters:
runnable - the runnable to execute.
timeout - the timeout for performing the operation.
See Also:
for more information.