Electron Plugin

The plugin provides the ability to test Electron-based desktop applications. VIVIDUS uses ChromeDriver functionality to interact with the application.

Installation

  1. Copy the below line to dependencies section of the project build.gradle file

    Example 1. build.gradle
    implementation(group: 'org.vividus', name: 'vividus-plugin-electron', version: '0.5.9')
  2. If the project was imported to the IDE before adding new plugin, re-generate the configuration files for the used IDE and then refresh the project in the used IDE.

Profile

The available profile is desktop/electron. It should be used together with web/desktop/chrome.

Example 2. configuration.properties
configuration.profiles=desktop/electron,web/desktop/chrome

Properties

The properties marked with bold are mandatory.
Property Name Acceptable values Default Description

electron-app.binary-path

An absolute file path.

The path to the executable file of the application under test.

electron-app.chromium-version

The version string, e.g. 102

The chromium version used to build the application. The simplest way to determine the version is to run the tests without this property and then you should receive error message like this one:

chrome driver version
Use major version e.g. 102.0

electron-app.comamand-line-arguments

The space-separated list of arguments e.g. --remote-debugging-port=9515 --user-dir=/Users/testtestius/temp.

<empty>

The list of command line arguments for the application.

Steps

In order to interact with the user interface one can use the steps from Web Application Plugin.

Start application

Starts the application under tests.

Given I start electron application
Example 3. Start the electron application
Given I start electron application
When I wait `PT1M` until window with title that contains ` | Microsoft Teams` appears and switch to it
When I wait until element located `id(searchInputField)` appears

Electron based applications may have one or more windows at the same time. Consider usage of the window waiting step to manipulate with the windows during testing.

You could also find the complete example for Elector-based desktop application tests here.

How to debug electron-based applications

When you are writing tests for the electron based application you have few options to use DevTools. The first one relies on the embedded DevTools. The second option is to use remote DevTools debugging. The simplest way is to start your application with --remote-debugging-port=<port> flag. Once the port is passed as an argument, DevTools will be available at http://localhost:<port>;

dev tools available windows
Figure 1. Available Application Windows
Example 4. Start electron app with the flag
/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron --remote-debugging-port=9222
dev tools
Figure 2. DevTools view