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

    Fields
    Modifier and Type
    Field
    Description
    com.vaadin.testbench.ScreenshotOnFailureRule
     

    Fields inherited from class com.vaadin.testbench.TestBenchTestCase

    driver, maxAttempts
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Calls the blur() function on the current active element of the page, if any.
    protected void
    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
    Clicks on the element, using JS.
    protected void
    clickElementWithJs(org.openqa.selenium.WebElement element)
    Clicks on the element, using JS.
    static void
     
    protected List<org.openqa.selenium.logging.LogEntry>
    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 String
     
    protected String
     
    protected String
    getTestURL(String... parameters)
     
    static String
    getTestURL(String rootUrl, String testPath, String... parameters)
     
    boolean
    isElementPresent(org.openqa.selenium.By by)
    Returns true if an element can be found from the driver with given selector.
    protected void
     
    protected void
    open(String... parameters)
     
    static void
     
    void
     
    void
     
    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
    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.

    Methods inherited from class com.vaadin.testbench.TestBenchTestCase

    concatUrl, executeScript, findElement, findElements, getCommandExecutor, getContext, getDriver, setDriver, testBench, waitUntil, waitUntil, wrap

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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

      public void resetDriver() throws Exception
      Throws:
      Exception
    • quitDriverPerMethod

      public void quitDriverPerMethod()
    • quitDriver

      public static void quitDriver()
    • getTestPath

      protected String getTestPath()
    • getRootURL

      protected String getRootURL()
    • getTestURL

      protected String getTestURL(String... parameters)
    • getTestURL

      public static String getTestURL(String rootUrl, String testPath, String... parameters)
    • open

      protected void open()
    • open

      protected void open(String... parameters)
    • 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

      protected void clickElementWithJs(String elementId)
      Clicks on the element, using JS. This method is more convenient than Selenium findElement(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

      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.
    • checkLogsForErrors

      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.
    • 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 the blur() function on the current active element of the page, if any.
    • getProperty

      public String getProperty(org.openqa.selenium.WebElement element, String propertyName)
      Gets a property value from a web element using JavaScript.