public class TestBenchHelpers
extends com.vaadin.testbench.parallel.ParallelTest
| Constructor and Description |
|---|
TestBenchHelpers() |
| Modifier and Type | Method and Description |
|---|---|
protected static void |
assertEquals(org.openqa.selenium.WebElement expectedElement,
org.openqa.selenium.WebElement actualElement)
Assert that the two elements are equal.
|
void |
blur()
Calls the
blur() function on the current active element of the
page, if any. |
protected void |
checkLogsForErrors()
Checks browser's log entries, throws an error for any client-side error
and logs any client-side warnings.
|
protected void |
checkLogsForErrors(Predicate<String> acceptableMessagePredicate)
Checks browser's log entries, throws an error for any client-side error
and logs any client-side warnings.
|
protected void |
clickElementWithJs(String elementId)
Clicks on the element, using JS.
|
protected void |
clickElementWithJs(org.openqa.selenium.WebElement element)
Clicks on the element, using JS.
|
void |
drag(org.openqa.selenium.WebElement source)
Simulate only a drag of
source. |
void |
dragAndDrop(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
Simulate DnD of
source element into the target element. |
void |
dragElementOver(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
Simulate a drag of
source element and over the target
element. |
protected Object |
executeScript(String script,
Object... args)
Executes the given JavaScript.
|
protected List<org.openqa.selenium.logging.LogEntry> |
getLogEntries(Level level)
Gets the log entries from the browser that have the given logging level
or higher.
|
protected int |
getScrollX()
Gets current scroll position on x axis.
|
protected int |
getScrollY()
Gets current scroll position on y axis.
|
protected boolean |
hasCssClass(org.openqa.selenium.WebElement element,
String className)
Checks if the given element has the given class name.
|
boolean |
isElementPresent(org.openqa.selenium.By by)
Returns true if an element can be found from the driver with given
selector.
|
protected void |
scrollBy(int deltaX,
int deltaY)
Scrolls the page by given amount of x and y deltas.
|
protected void |
scrollIntoViewAndClick(org.openqa.selenium.WebElement element)
Scrolls the page to the element specified and clicks it.
|
protected void |
scrollToElement(org.openqa.selenium.WebElement element)
Scrolls the page to the element given using javascript.
|
protected void |
waitForDevServer()
If dev server start in progress wait until it's started.
|
protected void |
waitForElementNotPresent(org.openqa.selenium.By by) |
protected void |
waitForElementPresent(org.openqa.selenium.By by) |
protected void |
waitForElementVisible(org.openqa.selenium.By by) |
protected <T> void |
waitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
Waits up to 10s for the given condition to become false.
|
protected <T> void |
waitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
long timeoutInSeconds)
Waits the given number of seconds for the given condition to become
false.
|
getDefaultCapabilities, getDesiredCapabilities, getHubHostname, getHubURL, getRunLocallyBrowser, getRunLocallyBrowserVersion, getRunOnHub, setDesiredCapabilities, setupconcatUrl, findElement, findElements, getCommandExecutor, getContext, getDriver, setDriver, testBench, waitUntil, waitUntil, wrapprotected <T> void waitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
waitUntilNot(ExpectedCondition).T - the return type of the expected conditioncondition - the condition to wait for to become falsepublic boolean isElementPresent(org.openqa.selenium.By by)
by - the selector used to find elementpublic void dragAndDrop(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
source element into the target element.source - target - public void drag(org.openqa.selenium.WebElement source)
source.source - public void dragElementOver(org.openqa.selenium.WebElement source,
org.openqa.selenium.WebElement target)
source element and over the target
element.source - target - protected <T> void waitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
long timeoutInSeconds)
waitUntilNot(ExpectedCondition).T - the return type of the expected conditioncondition - the condition to wait for to become falsetimeoutInSeconds - the number of seconds to waitprotected void waitForElementPresent(org.openqa.selenium.By by)
protected void waitForElementNotPresent(org.openqa.selenium.By by)
protected void waitForElementVisible(org.openqa.selenium.By by)
protected boolean hasCssClass(org.openqa.selenium.WebElement element,
String className)
element - the element to testclassName - the class names to matchtrue if matches, false if notprotected static void assertEquals(org.openqa.selenium.WebElement expectedElement,
org.openqa.selenium.WebElement actualElement)
Can be removed if https://dev.vaadin.com/ticket/18484 is fixed.
expectedElement - the expected elementactualElement - the actual elementprotected Object executeScript(String script, Object... args)
To send arguments to the script, you can use the arguments
variable.
For example:
executeScript("window.alert(arguments[0]);", "Alert message!");.
To be able to use the return value of the JavaScript, you must explicitly
declare a return statement.
For example: executeScript("return window.name;");.
executeScript in class com.vaadin.testbench.TestBenchTestCasescript - the script to executeargs - optional arguments for the scriptJavascriptExecutor.executeScript(String, Object...)
returnsprotected void scrollBy(int deltaX,
int deltaY)
deltaX - the offset in pixels to scroll horizontallydeltaY - the offset in pixels to scroll verticallyprotected void scrollToElement(org.openqa.selenium.WebElement element)
element - the element to scroll to, not nullprotected void scrollIntoViewAndClick(org.openqa.selenium.WebElement element)
element - the element to scroll to and clickprotected int getScrollX()
protected int getScrollY()
protected void clickElementWithJs(String elementId)
findElement(By.id(urlId)).click(), because Selenium
method changes scroll position, which is not always needed.elementId - id of theprotected void clickElementWithJs(org.openqa.selenium.WebElement element)
element.click(), because Selenium method changes scroll
position, which is not always needed.element - the element to be clicked onprotected List<org.openqa.selenium.logging.LogEntry> getLogEntries(Level level)
level - the minimum severity of logs includedprotected void checkLogsForErrors(Predicate<String> acceptableMessagePredicate)
acceptableMessagePredicate - allows to ignore log entries whose message is accaptableAssertionError - if an error is found in the browser logsprotected void checkLogsForErrors()
AssertionError - if an error is found in the browser logsprotected void waitForDevServer()
This is a workaround for an issue in TB: https://github.com/vaadin/testbench/issues/1244
public void blur()
blur() function on the current active element of the
page, if any.Copyright © 2000–2025 Vaadin Ltd. All rights reserved.