public class UITester extends UIFinder
LspsRemote.unloadAllModules()
in @Before and @After methodUIDefaultAppTester.login(String, String)
) in the @Before method
public static class MyTest {
// initializes the helper class
protected UITester app = new UITester(new FirefoxDriver());
// this will make a screenshot of the page on test failure
@Rule
public ScreenshotOnFailureRule screenshotOnFailureRule = new ScreenshotOnFailureRule(app, true);
@Before
public void prepare() {
LspsRemote.unloadAllModules();
app.login();
}
@After
public void cleanup() {
LspsRemote.unloadAllModules();
}
@Test
public void myTest() {
LspsRemote.uploadModule("mymodule", "1.0");
app.runModel("mymodule");
app.openTodo("mytodo");
final LspsTextBox name = app.find("NAME").as().textBox();
...
}
}
Note that the tester framework uses Vaadin TestBench. To use this framework, you need to obtain the TestBench license first.Modifier and Type | Field and Description |
---|---|
String |
contextRoot
Context root where the Vaadin Default app is deployed.
|
Constructor and Description |
---|
UITester(WebDriver driver)
Deprecated.
|
UITester(WebDriver driver,
String contextRoot) |
UITester(WebDriver driver,
String contextRoot,
int implicitWaitSeconds,
int pageLoadTimeoutSeconds,
int scriptTimeoutSeconds) |
Modifier and Type | Method and Description |
---|---|
void |
assertDocumentTitles(String... titles)
Asserts that there are the following documents available to the current user.
|
void |
assertUserSeesDocument(String documentName)
Checks that the currently logged-in user is able to open given document.
|
protected static void |
closeMenu(MenuBarElement menu) |
List<DocumentInfo> |
getDocuments()
Returns a list of documents displayed for the currently logged-in user.
|
List<String> |
getDocumentTitles()
Returns the titles of a list of document displayed for the currently logged-in user.
|
Person |
getLoggedInPerson() |
protected LspsRemote |
getRemote() |
List<Todo> |
getTodoList()
Obtains a complete list of TO-DOs for the currently logged-in user.
|
static By |
menuItemById(String titleKey)
Returns a locator for given menu item.
|
protected void |
mockLogIn(String username,
String password)
When your app differs greatly from the default app and
UIDefaultAppTester.login(String, String) wouldn't work,
you can log in via your custom TestBench/Selenium code. |
protected void |
mockLogout() |
void |
openTodo(String todoTitle)
Deprecated.
call
UIDefaultAppTester.openTodo(String) instead. |
ModelInstance |
runModel(String modelName)
Deprecated.
call
UIDefaultAppTester.runModel(String) instead. |
void |
waitForAttributeToBe(By locator,
String attribute,
String value)
Waits till the attribute gets given value.
|
void |
waitForElementPresent(By by)
Waits till the elements described by by shows up.
|
void |
waitForElementPresent(By by,
long timeOutInSeconds)
Waits till the elements described by by shows up.
|
$, actions, clickButton, contains, createIdLocator, findAllByAttributeValue, findAllByClassname, findAllByFormId, findAllById, findAllByIdPrefix, findAllByLspsId, findAllByTextContent, findAllByXpath, findByAttributeValue, findByClassname, findByFormId, findById, findByIdPrefix, findByLspsId, findByTextContent, findByXpath, findCaptionByTextContent, findElement, findElements, findNthByTag, getDriver, getLspsCommandExecutor, toString, waitForVaadin, webElementsByExactTextContent, webElementsByFormId, webElementsById, webElementsByIdPrefix, webElementsByLspsFormId, webElementsByLspsId, webElementsByTextContent, webElementsByXpath
public final String contextRoot
@Deprecated public UITester(WebDriver driver)
UIDefaultAppTester.UIDefaultAppTester(WebDriver)
.driver
- the web driver topublic UITester(WebDriver driver, String contextRoot)
public UITester(WebDriver driver, String contextRoot, int implicitWaitSeconds, int pageLoadTimeoutSeconds, int scriptTimeoutSeconds)
public void waitForElementPresent(By by)
by
- public void waitForAttributeToBe(By locator, String attribute, String value)
locator
- attribute
- value
- public void waitForElementPresent(By by, long timeOutInSeconds)
by
- timeOutInSeconds
- public static By menuItemById(String titleKey)
titleKey
- the title key as given to the NavigationMenu classprotected static void closeMenu(MenuBarElement menu)
protected void mockLogIn(String username, String password)
UIDefaultAppTester.login(String, String)
wouldn't work,
you can log in via your custom TestBench/Selenium code. Then, just call this function in order for other functions
to work properly.username
- password
- protected void mockLogout()
public Person getLoggedInPerson()
protected LspsRemote getRemote()
public List<Todo> getTodoList()
IllegalStateException
- if no user is currently logged in via mockLogIn(String, String)
.public List<DocumentInfo> getDocuments()
public List<String> getDocumentTitles()
public void assertUserSeesDocument(String documentName)
documentName
- the document name, not null.AssertionError
- if getDocuments()
does not contain given document.@Deprecated public void openTodo(String todoTitle)
UIDefaultAppTester.openTodo(String)
instead.UIDefaultAppTester.openTodo(String)
instead.todoTitle
- @Deprecated public ModelInstance runModel(String modelName)
UIDefaultAppTester.runModel(String)
instead.UIDefaultAppTester.runModel(String)
instead.modelName
- public void assertDocumentTitles(String... titles)
titles
- the expected document titles, not null.Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.