|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swtbot.swt.finder.SWTBot org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot
public class SWTWorkbenchBot
SWTWorkbenchBot is a SWTBot
with capabilities for testing Eclipse workbench items like views, editors and
perspectives
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)
|
|
|
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. |
|
|
widget(Matcher<T> matcher)
|
|
|
widget(Matcher<T> matcher,
int index)
|
|
|
widget(Matcher<T> matcher,
Widget parentWidget)
|
|
|
widget(Matcher<T> matcher,
Widget parentWidget,
int index)
|
|
|
widgets(Matcher<T> matcher)
|
|
|
widgets(Matcher<T> matcher,
Widget parentWidget)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@Deprecated public static final long DEFAULT_POLL_DELAY
protected final Display display
protected final Finder finder
Constructor Detail |
---|
public SWTWorkbenchBot()
Method Detail |
---|
public SWTBotPerspective perspective(Matcher<?> matcher)
matcher
- the matcher used to find the perspective
WidgetNotFoundException
- if the perspective is not foundpublic SWTBotPerspective perspectiveByLabel(String label)
label
- the "human readable" label for the perspective
label
perspective(Matcher)
,
WidgetMatcherFactory.withPerspectiveLabel(Matcher)
public SWTBotPerspective perspectiveById(String id)
id
- the perspective id
label
perspective(Matcher)
,
WidgetMatcherFactory.withPerspectiveId(Matcher)
public List<SWTBotPerspective> perspectives(Matcher<?> matcher)
matcher
- Matcher for IPerspectiveDescriptor
public List<SWTBotPerspective> perspectives()
public SWTBotView view(Matcher<IViewReference> matcher)
matcher
- the matcher used to match views
WidgetNotFoundException
- if the view is not foundpublic SWTBotView viewByTitle(String title)
title
- the "human readable" title
WidgetMatcherFactory.withPartName(Matcher)
public SWTBotView viewById(String id)
id
- the view id
WidgetMatcherFactory.withPartId(String)
public List<SWTBotView> views(Matcher<?> matcher)
matcher
- the matcher used to find views
public List<SWTBotView> views()
public SWTBotView activeView()
WidgetNotFoundException
- if there is no active viewpublic SWTBotEditor editor(Matcher<IEditorReference> matcher)
matcher
- the matcher used to find the editor
WidgetNotFoundException
- if the editor is not foundpublic List<SWTBotEditor> editors(Matcher<?> matcher)
matcher
- the matcher used to find all editors
public List<? extends SWTBotEditor> editors()
public SWTBotEditor editorByTitle(String fileName)
fileName
- the the filename on the editor tab
editor(Matcher)
public SWTBotEditor editorById(String id)
id
- the the id on the editor tab
editor(Matcher)
public SWTBotEditor activeEditor()
WidgetNotFoundException
- if there is no active viewpublic SWTBotMultiPageEditor multipageEditor(Matcher<IEditorReference> matcher)
matcher
- the matcher used to find the editor
WidgetNotFoundException
- if the editor is not foundpublic List<SWTBotMultiPageEditor> multipageEditors(Matcher<?> matcher)
matcher
- the matcher used to find all editors
public List<? extends SWTBotMultiPageEditor> multipageEditors()
public SWTBotMultiPageEditor multipageEditorByTitle(String fileName)
fileName
- the the filename on the editor tab
editor(Matcher)
public SWTBotMultiPageEditor multipageEditorById(String id)
id
- the the id on the editor tab
editor(Matcher)
public SWTBotPerspective activePerspective()
public void resetWorkbench()
public SWTBotPerspective defaultPerspective()
public void closeAllEditors()
public void saveAllEditors()
public SWTBotPerspective resetActivePerspective()
public void closeAllShells()
public SWTBotShell shell(String text)
text
- the text on the shell.
public SWTBotShell shell(String text, int index)
text
- the text on the shell.index
- the index of the shell, in case there are multiple shells with the same text.
Shell
with the specified index.public List<Shell> shells(String text)
text
- the text on the shell.
Shell
with the specified index.public SWTBotShell shell(String text, Shell parent)
text
- the text on the shell.parent
- the parent under which a shell will be found.
public SWTBotShell shell(String text, Shell parent, int index)
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.
Shell
with the specified index.public List<Shell> shells(String text, Shell parent)
text
- the text on the shell.parent
- the parent under which a shell will be found.
Shell
which matched.public SWTBotShell shellWithId(String value)
value
- the value of the id
public SWTBotShell shellWithId(String key, String value)
key
- the key of the idvalue
- the value of the id
public SWTBotShell shellWithId(String value, int index)
value
- the value of the idindex
- the index of the shell, in case there are multiple shells with the same text.
public SWTBotShell shellWithId(String key, String value, int index)
key
- the key of the idvalue
- the value of the idindex
- the index of the shell, in case there are multiple shells with the same text.
public SWTBotMenu menu(String text)
text
- the text on the menu.
public SWTBotMenu menu(String text, int index)
text
- the text on the menu.index
- the index of the menu, in case there are multiple menus with the same text.
public SWTBotMenu menuWithId(String value)
value
- the value of the id.
public SWTBotMenu menuWithId(String value, int index)
value
- the value of the id.index
- the index of the menu item, in case there are multiple shells with the same text.
public SWTBotMenu menuWithId(String key, String value)
key
- the key of the id.value
- the value of the id.
public SWTBotMenu menuWithId(String key, String value, int index)
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.
public SWTBotMenu menu(SWTBotShell shell, Matcher<MenuItem> matcher, int index)
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.
public <T extends Widget> List<? extends T> widgets(Matcher<T> matcher, Widget parentWidget)
matcher
- the matcher used to match widgets.parentWidget
- the parent widget to search for a given widget.
public <T extends Widget> List<? extends T> widgets(Matcher<T> matcher)
matcher
- the matcher used to match widgets.
public <T extends Widget> T widget(Matcher<T> matcher, Widget parentWidget)
matcher
- the matcher used to match widgets.parentWidget
- the parent widget to search for a given widget.
public <T extends Widget> T widget(Matcher<T> matcher, Widget parentWidget, int index)
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
public <T extends Widget> T widget(Matcher<T> matcher, int index)
matcher
- the matcher used to match widgets.index
- the index of the widget in case there are multiple widgets.
public <T extends Widget> T widget(Matcher<T> matcher)
matcher
- the matcher used to match widgets.
public SWTBotShell[] shells()
public SWTBotShell activeShell() throws WidgetNotFoundException
WidgetNotFoundException
- if the widget is not found.public void waitUntilWidgetAppears(ICondition waitForWidget)
public void waitUntil(ICondition condition) throws TimeoutException
condition
- the ICondition
to be evaluated.
TimeoutException
- if the condition does not evaluate to true after SWTBotPreferences.TIMEOUT
milliseconds.public void waitUntil(ICondition condition, long timeout) throws TimeoutException
condition
- the condition to be evaluated.timeout
- the timeout.
TimeoutException
- if the condition does not evaluate to true after timeout milliseconds.public void waitUntil(ICondition condition, long timeout, long interval) throws TimeoutException
condition
- the condition to be evaluated.timeout
- the timeout.interval
- The delay time.
TimeoutException
- if the condition does not evaluate to true after timeout milliseconds.public void waitWhile(ICondition condition) throws TimeoutException
condition
- the ICondition
to be evaluated.
TimeoutException
- if the condition does not evaluate to false after SWTBotPreferences.TIMEOUT
milliseconds.public void waitWhile(ICondition condition, long timeout) throws TimeoutException
condition
- the condition to be evaluated.timeout
- the timeout.
TimeoutException
- if the condition does not evaluate to false after timeout milliseconds.public void waitWhile(ICondition condition, long timeout, long interval) throws TimeoutException
condition
- the condition to be evaluated.timeout
- the timeout.interval
- The delay time.
TimeoutException
- if the condition does not evaluate to false after timeout milliseconds.public void sleep(long millis)
millis
- the time in milliseconds for which to sleep.public Display getDisplay()
public boolean captureScreenshot(String fileName)
fileName
- the filename to save screenshot to.
true
if the screenshot was created and saved, false
otherwise.SWTUtils.captureScreenshot(String)
public Finder getFinder()
public Control getFocusedWidget()
null
if keyboard events are not currently
going to any of the controls built by the currently running application.
null
Display.getFocusControl()
public SWTBotTrayItem trayItem()
SWTBotTrayItem
public SWTBotTrayItem trayItem(int index)
index
- he index of the tray item.
SWTBotTrayItem
at specified index
public SWTBotTrayItem trayItemWithTooltip(String tooltip)
tooltip
- the tooltip on the tray item.
SWTBotTrayItem
with the specified tooltip
.public SWTBotTrayItem trayItemWithTooltip(String tooltip, int index)
tooltip
- the tooltip on the tray item.index
- the index of the tray item.
SWTBotTrayItem
with the specified tooltip
.public List<SWTBotTrayItem> trayItems()
public List<SWTBotTrayItem> trayItems(Matcher<?> matcher)
matcher
- the matcher used to match tray item
SWTBotTrayItem
matching the matcher.protected Tray systemTray()
public <T> T performWithTimeout(Result<T> runnable, long timeout)
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);
runnable
- the runnable to execute.timeout
- the timeout for performing the operation.
public void performWithTimeout(VoidResult runnable, long timeout)
runnable
- the runnable to execute.timeout
- the timeout for performing the operation.for more information.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |