Since version 4.5 QF-Test can handle applications developed via the Electron framework. All features QF-Test supports for the web engine can also be used for Electron testing.
The Electron specific parameters for the quickstart wizard will be explained in this chapter. For the remaining optional parameters you will find an explanation within the quickstart wizard itself.
The video shows ' Starting your Electron application via the Quickstart wizard'.
In the quickstart wizard select
An Electron application in the
section 'Type of the Application'.
Please enter the fully qualified executable for the application in the section 'Electron application'. You can make use of the file selection dialog by clicking the button to the right of the text field. If your application requires specific command line arguments, you can provide them here.
environment 'V8'. Since Electron 6 and QF-Test 5.4.0 the CDP-Driver connection mode
is used to control the application. Older applications require the
WebDriver connection mode in combination with a ChromeDriver. In most cases,
QF-Test detects the required ChromeDriver automatically and downloads it.
The downloaded driver will be saved in the subdirectory
chromedriver of the QF-Test installation directory.
For Electron testing you can use all the features QF-Test offers for web testing plus the following:
The 'Selection' node allows you to control native menus in Electron applications.
Please enter the 'QF-Test ID' of the node
Web page of the SUT in the
attribute 'QF-Test component ID'.
The menu item to be selected goes in the 'Detail' attribute
using the following syntax:
clickmenu:/@<menu path>, where
<menu path> is the menu name plus the menu item(s), separated by
/. For example, if you want to select the menu item
Save as in the menu
File the correct entry would be
QF-Test supports capture, check and control of dialogs instantiated with the
dialog-module of Electron.
For technical reasons, during the test the dialogs can be optically different from the usual Electron-dialogs.
A capture of a native dialog results in a component-node with the class
It is possible to check the text of the dialog-window using a node 'Check text'.
The interaction with the dialog-window can be performed using a node 'Selection'.
The 'Detail' value of a 'Selection'-node depends on a type of the dialog:
2. If the Message Box contains a CheckBox, it is possible to append its value separated with
["file.txt","C:\\TEMP\\other.txt"]. It is possible to cancel the dialog by setting the 'Detail'-attribute to
In Electron applications separate render processes control the content view of the application windows.
In addition, a so called main process, built upon the Node.js engine, executes the main application logic.
To execute individual code in the context of this process, QF-Test provides the method
as powerfull extension of the
DocumentNode-API (see subsection 50.11.2).
In the example, the "Chrome Developer Tools"" will be displayed in the current Electron window.
|Example 19.1: SUT-skript to display the Dev Tools in an Electron window|
To support testing the Electron APIs, e.g. record and replay native menu interaction,
QF-Test has to be able to access the core Electron APIs in WebDriver connection mode
from the renderer processes of your application.
In practice, this means that the
nodeIntegration preference of the BrowserWindow should
not be set to
false. In addition,
contextIsolation must be left deactivated and
enableRemoteModule must remain
|Example 19.2: Basic example for good testability in Electron apps|
If you want to avoid to expose the complete node integration into the browser window web content, you can enable QF-Test to access the API integration using a preload script:
|Example 19.3: The require preferences for limited node integration|
|Example 19.4: The corresponding |
Since QF-Test always sets the
NODE_ENV environment variable to
test, you can
use this to dynamically loosen the access security during test:
|Example 19.5: Dynamic example for good testability in Electron apps|
Starting with Electron 14, the
remote module is not part of the Electron API anymore, but
must be explicitly included. To do so, add at development time a reference to the
module in your
package.json and initialize the module in your
|Example 19.6: How to initialize the |
QF-Test automatically uses the new module if detected. More information about the module can be found it the documentation at https://github.com/electron/remote/.
When using the CDP-Driver connection mode, no specific adaptation of the Electron application is required for QF-Test.
|Last update: 3/18/2022|
Copyright © 1999-2022 Quality First Software GmbH