Docs

Documentation versions (currently viewingVaadin 24)

Setting Up a Test Grid

Explanations and examples on setting up a test grid.

TestBench is based on Selenium and doesn’t contain any modifications to the grid hub/node part. This means that you can run TestBench tests on any available Selenium grid. Also, setting up a grid is exactly like setting up a Selenium grid.

Setting Up the Docker-Based Selenium Grid

Ready-made Docker images for setting up a Selenium Grid are available at https://github.com/SeleniumHQ/docker-selenium. To use these images, you first need to install Docker.

Once you have Docker installed, you can create your own test grid, for example using docker-compose.

First, create the following docker-compose.yaml in an empty folder:

version: '2'
services:
  firefox:
    image: selenium/node-firefox:3.9.1-actinium
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_HOST: hub

  chrome:
    image: selenium/node-chrome:3.9.1-actinium
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - hub
    environment:
      HUB_HOST: hub

  hub:
    image: selenium/hub:3.9.1-actinium
    ports:
      - "4444:4444"

This defines a grid with one Chrome node and one Firefox node in addition to the hub.

The whole grid can then be started like this:

docker-compose up

This starts a grid on http://localhost:4444, with the console at http://localhost:4444/grid/console so you can run your tests on the hub using @RunOnHub("localhost").

Note
The communication protocol used by the grid is standardized, so it shouldn’t be critical to match the Selenium version on which TestBench is based with the version of the grid. If you run into some odd issues, try matching the versions. You can check the Selenium version for TestBench here

Setting Up a Custom Selenium Grid

The process for setting up your own custom Selenium grid is described at https://seleniumhq.github.io/docs/grid.html#rolling_your_own_grid. All of the instructions for Selenium apply also to TestBench.

Settings for Screenshots

The screenshot comparison feature requires that the user interface of the browser should stay constant. The exact features that interfere with testing depend on the browser and the operating system. These are in general the following:

  • Disable cursor blinking;

  • Use the exact same operating system and browser version on every host;

  • Turn off any software that may suddenly pop up a new window; and

  • Turn off the screen saver.

If you’re using Windows and Internet Explorer, you should also turn on Allow active content to run in files on My Computer in Security settings.

Mobile Testing

Vaadin TestBench includes an iPhone and an Android driver, with which you can test on mobile devices. The tests can be run in either a device or an emulator/simulator.

The actual testing is like with any WebDriver, using either the IPhoneDriver or the AndroidDriver. The Android driver assumes that the hub (android-server) is installed in the emulator and forwarded to port 8080 in localhost, while the iPhone driver assumes port 3001. You can also use the RemoteWebDriver with either the iphone() or the android() capability, and specify the hub URI, explicitly.

The mobile testing setup is covered in detail in the Selenium documentation for both the iOS driver and the AndroidDriver.

60915066-085F-4C16-9486-506024D86CFD