Class AbstractViewTest

java.lang.Object
com.vaadin.testbench.TestBenchTestCase
com.vaadin.collaborationengine.util.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
    protected final boolean
     
    protected final boolean
     
    protected final boolean
     
    protected final boolean
     
    com.vaadin.testbench.ScreenshotOnFailureRule
     

    Fields inherited from class com.vaadin.testbench.TestBenchTestCase

    driver, maxAttempts
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    protected void
    assertThemePresentOnElement(org.openqa.selenium.WebElement element, Class<? extends com.vaadin.flow.theme.AbstractTheme> themeClass)
    Asserts that the given element is rendered using a theme identified by themeClass.
    void
     
    protected org.openqa.selenium.WebDriver
     
    protected org.openqa.selenium.WebElement
    Convenience method for getting the root element of the view based on the selector passed to the constructor.
    abstract String
    Get the route of the view to navigate to.
    protected String
    Returns deployment host name concatenated with route.
    protected String
    getURL(String path)
    Returns deployment host name concatenated with route.
    protected void
     
    void
     

    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

    • isSauce

      protected final boolean isSauce
    • isHub

      protected final boolean isHub
    • isLocal

      protected final boolean isLocal
    • isHeadless

      protected final boolean isHeadless
    • rule

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

    • AbstractViewTest

      public AbstractViewTest()
    • AbstractViewTest

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

    • setup

      public void setup() throws Exception
      Throws:
      Exception
    • close

      public void close()
    • refresh

      protected void refresh()
    • createDriver

      protected org.openqa.selenium.WebDriver createDriver() throws Exception
      Throws:
      Exception
    • 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, 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 String getURL()
      Returns deployment host name concatenated with route.
      Returns:
      URL to route
    • getURL

      protected String getURL(String path)
      Returns deployment host name concatenated with route.
      Parameters:
      path - route path
      Returns:
      URL to route
    • getRoute

      public abstract 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.