Package com.vaadin.tests
Class AbstractComponentIT
java.lang.Object
com.vaadin.testbench.TestBenchTestCase
com.vaadin.tests.AbstractComponentIT
- All Implemented Interfaces:
com.vaadin.testbench.HasDriver,com.vaadin.testbench.HasElementQuery,com.vaadin.testbench.HasSearchContext,com.vaadin.testbench.HasTestBenchCommandExecutor
- Direct Known Subclasses:
AbstractValidationIT
public abstract class AbstractComponentIT
extends com.vaadin.testbench.TestBenchTestCase
Base class for Flow component integration tests.
Extends TestBenchTestCase directly and manages a headless Chrome
driver that is reused across all test methods in the same test class. By
default the driver is started locally; setting -Dtest.use.hub=true
routes driver creation to a Selenium Grid endpoint configured via
-Dtest.hub.url (default http://localhost:4444/wd/hub).
This test setup does not support running tests in parallel. The only way to
parallelize tests is forking separate JVMs that run one suite at a time, for
example using failsafe.forkCount.
Test classes must be annotated with TestPath to specify the URL path
of the test view.
-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.vaadin.testbench.ScreenshotOnFailureRuleFields inherited from class com.vaadin.testbench.TestBenchTestCase
driver, maxAttempts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidblur()Calls theblur()function on the current active element of the page, if any.protected voidChecks browser's log entries, throws an error for any client-side error and logs any client-side warnings.protected voidcheckLogsForErrors(Predicate<String> acceptableMessagePredicate) Checks browser's log entries, throws an error for any client-side error and logs any client-side warnings.protected voidclickElementWithJs(String elementId) Clicks on the element, using JS.protected voidclickElementWithJs(org.openqa.selenium.WebElement element) Clicks on the element, using JS.static voidprotected List<org.openqa.selenium.logging.LogEntry> getLogEntries(Level level) Gets the log entries from the browser that have the given logging level or higher.getProperty(org.openqa.selenium.WebElement element, String propertyName) Gets a property value from a web element using JavaScript.protected Stringprotected Stringprotected StringgetTestURL(String... parameters) static StringgetTestURL(String rootUrl, String testPath, String... parameters) booleanisElementPresent(org.openqa.selenium.By by) Returns true if an element can be found from the driver with given selector.protected voidopen()protected voidstatic voidvoidvoidprotected voidscrollIntoViewAndClick(org.openqa.selenium.WebElement element) Scrolls the page to the element specified and clicks it.protected voidscrollToElement(org.openqa.selenium.WebElement element) Scrolls the page to the element given using javascript.protected voidIf dev server start in progress wait until it's started.protected voidwaitForElementNotPresent(org.openqa.selenium.By by) protected voidwaitForElementPresent(org.openqa.selenium.By by) protected voidwaitForElementVisible(org.openqa.selenium.By by) protected <T> voidwaitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition) Waits up to 10s for the given condition to become false.protected <T> voidwaitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition, long timeoutInSeconds) Waits the given number of seconds for the given condition to become false.Methods inherited from class com.vaadin.testbench.TestBenchTestCase
concatUrl, executeScript, findElement, findElements, getCommandExecutor, getContext, getDriver, setDriver, testBench, waitUntil, waitUntil, wrapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.testbench.HasElementQuery
$, $
-
Field Details
-
screenshotOnFailure
public com.vaadin.testbench.ScreenshotOnFailureRule screenshotOnFailure
-
-
Constructor Details
-
AbstractComponentIT
public AbstractComponentIT()
-
-
Method Details
-
createDriver
public static void createDriver() -
resetDriver
- Throws:
Exception
-
quitDriverPerMethod
public void quitDriverPerMethod() -
quitDriver
public static void quitDriver() -
getTestPath
-
getRootURL
-
getTestURL
-
getTestURL
-
open
protected void open() -
open
-
waitUntilNot
protected <T> void waitUntilNot(org.openqa.selenium.support.ui.ExpectedCondition<T> condition) Waits up to 10s for the given condition to become false. -
waitUntilNot
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. -
isElementPresent
public boolean isElementPresent(org.openqa.selenium.By by) Returns true if an element can be found from the driver with given selector. -
clickElementWithJs
Clicks on the element, using JS. This method is more convenient than SeleniumfindElement(By.id(urlId)).click(), because Selenium method changes scroll position, which is not always needed. -
clickElementWithJs
protected void clickElementWithJs(org.openqa.selenium.WebElement element) Clicks on the element, using JS. -
waitForElementPresent
protected void waitForElementPresent(org.openqa.selenium.By by) -
waitForElementNotPresent
protected void waitForElementNotPresent(org.openqa.selenium.By by) -
waitForElementVisible
protected void waitForElementVisible(org.openqa.selenium.By by) -
scrollToElement
protected void scrollToElement(org.openqa.selenium.WebElement element) Scrolls the page to the element given using javascript. -
scrollIntoViewAndClick
protected void scrollIntoViewAndClick(org.openqa.selenium.WebElement element) Scrolls the page to the element specified and clicks it. -
getLogEntries
Gets the log entries from the browser that have the given logging level or higher. -
checkLogsForErrors
Checks browser's log entries, throws an error for any client-side error and logs any client-side warnings. -
checkLogsForErrors
protected void checkLogsForErrors()Checks browser's log entries, throws an error for any client-side error and logs any client-side warnings. -
waitForDevServer
protected void waitForDevServer()If dev server start in progress wait until it's started. Otherwise return immediately. -
blur
public void blur()Calls theblur()function on the current active element of the page, if any. -
getProperty
Gets a property value from a web element using JavaScript.
-