Class AbstractViewTest

  • All Implemented Interfaces:
    com.vaadin.testbench.HasDriver, com.vaadin.testbench.HasElementQuery, com.vaadin.testbench.HasSearchContext, com.vaadin.testbench.HasTestBenchCommandExecutor
    Direct Known Subclasses:
    AbstractCollaborativeViewTest

    public abstract class AbstractViewTest
    extends com.vaadin.testbench.TestBenchTestCase
    Base class for TestBench IntegrationTests on chrome.

    The tests use Chrome driver (see pom.xml for integration-tests profile) to run integration tests on a headless Chrome. If a property test.use .hub is set to true, AbstractViewTest will assume that the TestBench test is running in a CI environment. In order to keep the this class light, it makes certain assumptions about the CI environment (such as available environment variables). It is not advisable to use this class as a base class for you own TestBench tests.

    To learn more about TestBench, visit Vaadin TestBench.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      com.vaadin.testbench.ScreenshotOnFailureRule rule  
      • Fields inherited from class com.vaadin.testbench.TestBenchTestCase

        driver, maxAttempts, testbenchVersion
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        AbstractViewTest()  
      protected AbstractViewTest​(org.openqa.selenium.By rootSelector)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void assertThemePresentOnElement​(org.openqa.selenium.WebElement element, java.lang.Class<? extends com.vaadin.flow.theme.AbstractTheme> themeClass)
      Asserts that the given element is rendered using a theme identified by themeClass.
      void close()  
      protected org.openqa.selenium.WebDriver createHeadlessChromeDriver()  
      protected org.openqa.selenium.WebElement getRootElement()
      Convenience method for getting the root element of the view based on the selector passed to the constructor.
      abstract java.lang.String getRoute()
      Get the route of the view to navigate to.
      protected java.lang.String getURL()
      Returns deployment host name concatenated with route.
      protected java.lang.String getURL​(java.lang.String path)  
      protected void refresh()  
      void setup()  
      static void setupClass()  
      • 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 Detail

      • rule

        public com.vaadin.testbench.ScreenshotOnFailureRule rule
    • Constructor Detail

      • AbstractViewTest

        public AbstractViewTest()
      • AbstractViewTest

        protected AbstractViewTest​(org.openqa.selenium.By rootSelector)
    • Method Detail

      • setupClass

        public static void setupClass()
      • setup

        public void setup()
      • close

        public void close()
      • refresh

        protected void refresh()
      • createHeadlessChromeDriver

        protected org.openqa.selenium.WebDriver createHeadlessChromeDriver()
      • getRootElement

        protected org.openqa.selenium.WebElement getRootElement()
        Convenience method for getting the root element of the view based on the selector passed to the constructor.
        Returns:
        the root element
      • assertThemePresentOnElement

        protected void assertThemePresentOnElement​(org.openqa.selenium.WebElement element,
                                                   java.lang.Class<? extends com.vaadin.flow.theme.AbstractTheme> themeClass)
        Asserts that the given element is rendered using a theme identified by themeClass. If the the is not found, JUnit assert will fail the test case.
        Parameters:
        element - web element to check for the theme
        themeClass - theme class (such as Lumo.class
      • getURL

        protected java.lang.String getURL()
        Returns deployment host name concatenated with route.
        Returns:
        URL to route
      • getURL

        protected java.lang.String getURL​(java.lang.String path)
      • getRoute

        public abstract java.lang.String getRoute()
        Get the route of the view to navigate to. In most cases it should be the same as the value in the @Route annotation of the view.