org.eclipse.swtbot.forms.finder
Class SWTFormsBot

java.lang.Object
  extended by org.eclipse.swtbot.swt.finder.SWTBot
      extended by org.eclipse.swtbot.forms.finder.SWTFormsBot

public class SWTFormsBot
extends SWTBot

SWTFormsBot is a SWTBot with capabilities for testing eclipse forms.

See Also:
SWTBot} - SWTBot for usage examples.

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
SWTFormsBot()
          Constructs a bot.
SWTFormsBot(ControlFinder controlFinder, MenuFinder menuFinder)
          Constructs an instance of the bot using the given control finder and menu finder.
SWTFormsBot(Finder finder)
          Constructs a bot with the given finder.
SWTFormsBot(Widget parent)
          Constructs a bot that will match the contents of the given parentWidget.
 
Method Summary
 SWTBotShell activeShell()
          Gets the current active shell.
 boolean captureScreenshot(String fileName)
          Captures a screenshot to the given file name.
 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.
 SWTBotHyperlink hyperlink()
           
 SWTBotHyperlink hyperlink(int index)
           
 SWTBotHyperlink hyperlink(String mnemonicText)
           
 SWTBotHyperlink hyperlink(String mnemonicText, int index)
           
 SWTBotHyperlink hyperlinkInGroup(String inGroup)
           
 SWTBotHyperlink hyperlinkInGroup(String inGroup, int index)
           
 SWTBotHyperlink hyperlinkInGroup(String mnemonicText, String inGroup)
           
 SWTBotHyperlink hyperlinkInGroup(String mnemonicText, String inGroup, int index)
           
 SWTBotHyperlink hyperlinkWithId(String value)
           
 SWTBotHyperlink hyperlinkWithId(String value, int index)
           
 SWTBotHyperlink hyperlinkWithId(String key, String value)
           
 SWTBotHyperlink hyperlinkWithId(String key, String value, int index)
           
 SWTBotImageHyperlink imageHyperlink()
           
 SWTBotImageHyperlink imageHyperlink(int index)
           
 SWTBotImageHyperlink imageHyperlink(String mnemonicText)
           
 SWTBotImageHyperlink imageHyperlink(String mnemonicText, int index)
           
 SWTBotImageHyperlink imageHyperlinkInGroup(String inGroup)
           
 SWTBotImageHyperlink imageHyperlinkInGroup(String inGroup, int index)
           
 SWTBotImageHyperlink imageHyperlinkInGroup(String mnemonicText, String inGroup)
           
 SWTBotImageHyperlink imageHyperlinkInGroup(String mnemonicText, String inGroup, int index)
           
 SWTBotImageHyperlink imageHyperlinkWithId(String value)
           
 SWTBotImageHyperlink imageHyperlinkWithId(String value, int index)
           
 SWTBotImageHyperlink imageHyperlinkWithId(String key, String value)
           
 SWTBotImageHyperlink imageHyperlinkWithId(String key, String value, int index)
           
 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)
           
<T> T
performWithTimeout(Result<T> runnable, long timeout)
          Performs an operation with a timeout and return a result.
 void performWithTimeout(VoidResult runnable, long timeout)
           
 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)
           
 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

SWTFormsBot

public SWTFormsBot()
Constructs a bot.


SWTFormsBot

public SWTFormsBot(Widget parent)
Constructs a bot that will match the contents of the given parentWidget.

Parameters:
parent - the parent

SWTFormsBot

public SWTFormsBot(ControlFinder controlFinder,
                   MenuFinder menuFinder)
Constructs an instance of the bot using the given control finder and menu finder.

Parameters:
controlFinder - the ControlFinder used to identify and find controls.
menuFinder - the MenuFinder used to find menu items.

SWTFormsBot

public SWTFormsBot(Finder finder)
Constructs a bot with the given finder.

Parameters:
finder - the finder.
Method Detail

hyperlink

public SWTBotHyperlink hyperlink(String mnemonicText)
Parameters:
mnemonicText - the mnemonicText on the widget.
Returns:
a SWTBotHyperlink with the specified mnemonicText.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlink

public SWTBotHyperlink hyperlink(String mnemonicText,
                                 int index)
Parameters:
mnemonicText - the mnemonicText on the widget.
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified mnemonicText.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkWithId

public SWTBotHyperlink hyperlinkWithId(String key,
                                       String value)
Parameters:
key - the key set on the widget.
value - the value for the key.
Returns:
a SWTBotHyperlink with the specified key/value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkWithId

public SWTBotHyperlink hyperlinkWithId(String key,
                                       String value,
                                       int index)
Parameters:
key - the key set on the widget.
value - the value for the key.
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified key/value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkWithId

public SWTBotHyperlink hyperlinkWithId(String value)
Parameters:
value - the value for the key SWTBotPreferences.DEFAULT_KEY.
Returns:
a SWTBotHyperlink with the specified value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkWithId

public SWTBotHyperlink hyperlinkWithId(String value,
                                       int index)
Parameters:
value - the value for the key SWTBotPreferences.DEFAULT_KEY.
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkInGroup

public SWTBotHyperlink hyperlinkInGroup(String inGroup)
Parameters:
inGroup - the inGroup on the widget.
Returns:
a SWTBotHyperlink with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkInGroup

public SWTBotHyperlink hyperlinkInGroup(String inGroup,
                                        int index)
Parameters:
inGroup - the inGroup on the widget.
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlink

public SWTBotHyperlink hyperlink()
Returns:
a SWTBotHyperlink with the specified none.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlink

public SWTBotHyperlink hyperlink(int index)
Parameters:
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified none.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkInGroup

public SWTBotHyperlink hyperlinkInGroup(String mnemonicText,
                                        String inGroup)
Parameters:
mnemonicText - the mnemonicText on the widget.
inGroup - the inGroup on the widget.
Returns:
a SWTBotHyperlink with the specified mnemonicText with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

hyperlinkInGroup

public SWTBotHyperlink hyperlinkInGroup(String mnemonicText,
                                        String inGroup,
                                        int index)
Parameters:
mnemonicText - the mnemonicText on the widget.
inGroup - the inGroup on the widget.
index - the index of the widget.
Returns:
a SWTBotHyperlink with the specified mnemonicText with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlink

public SWTBotImageHyperlink imageHyperlink(String mnemonicText)
Parameters:
mnemonicText - the mnemonicText on the widget.
Returns:
a SWTBotImageHyperlink with the specified mnemonicText.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlink

public SWTBotImageHyperlink imageHyperlink(String mnemonicText,
                                           int index)
Parameters:
mnemonicText - the mnemonicText on the widget.
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified mnemonicText.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkWithId

public SWTBotImageHyperlink imageHyperlinkWithId(String key,
                                                 String value)
Parameters:
key - the key set on the widget.
value - the value for the key.
Returns:
a SWTBotImageHyperlink with the specified key/value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkWithId

public SWTBotImageHyperlink imageHyperlinkWithId(String key,
                                                 String value,
                                                 int index)
Parameters:
key - the key set on the widget.
value - the value for the key.
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified key/value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkWithId

public SWTBotImageHyperlink imageHyperlinkWithId(String value)
Parameters:
value - the value for the key SWTBotPreferences.DEFAULT_KEY.
Returns:
a SWTBotImageHyperlink with the specified value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkWithId

public SWTBotImageHyperlink imageHyperlinkWithId(String value,
                                                 int index)
Parameters:
value - the value for the key SWTBotPreferences.DEFAULT_KEY.
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified value.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkInGroup

public SWTBotImageHyperlink imageHyperlinkInGroup(String inGroup)
Parameters:
inGroup - the inGroup on the widget.
Returns:
a SWTBotImageHyperlink with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkInGroup

public SWTBotImageHyperlink imageHyperlinkInGroup(String inGroup,
                                                  int index)
Parameters:
inGroup - the inGroup on the widget.
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlink

public SWTBotImageHyperlink imageHyperlink()
Returns:
a SWTBotImageHyperlink with the specified none.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlink

public SWTBotImageHyperlink imageHyperlink(int index)
Parameters:
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified none.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkInGroup

public SWTBotImageHyperlink imageHyperlinkInGroup(String mnemonicText,
                                                  String inGroup)
Parameters:
mnemonicText - the mnemonicText on the widget.
inGroup - the inGroup on the widget.
Returns:
a SWTBotImageHyperlink with the specified mnemonicText with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

imageHyperlinkInGroup

public SWTBotImageHyperlink imageHyperlinkInGroup(String mnemonicText,
                                                  String inGroup,
                                                  int index)
Parameters:
mnemonicText - the mnemonicText on the widget.
inGroup - the inGroup on the widget.
index - the index of the widget.
Returns:
a SWTBotImageHyperlink with the specified mnemonicText with the specified inGroup.
Throws:
WidgetNotFoundException - if the widget is not found or is disposed.

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.