Applies to TestLeft 4.30, last modified on November 21, 2019

The Electron framework is used to create applications with JavaScript. The user interface of such applications is implemented as web pages that the Chromium web browser embedded into the application renders. With TestLeft, you can create automated tests for applications created with Electron.

Supported Electron Versions

TestLeft can test 32- and 64-bit applications created with Electron version 1.8.2, 2.0.2, 3.0.2, 4.0.2, 5.0.0, 6.0.0, 7.0.0.

Note: We do not guarantee that your tests will work with applications created with other versions of Electron.

Requirements

  • Your tested Electron application must be compiled as a binary executable file. See the Application Distribution section in the Electron documentation.

  • Run your Electron application by using the ApplicationManager.Run method:

    C#

    using SmartBear.TestLeft;


    string appPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    appPath += @"\Orders\app-1.0.0\orders.exe";

    // Runs the Electron-based application
    Driver.Applications.Run(appPath);

    Visual Basic .NET

    Imports SmartBear.TestLeft

    Dim appPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
    appPath = appPath & "\Orders\app-1.0.0\orders.exe"

    ' Runs the Electron-based application Driver.Applications.Run(appPath)

    Java

    import com.smartbear.testleft.*;
    import com.smartbear.testleft.testobjects.*;


    String appPath = System.getenv("LOCALAPPDATA");
    appPath += "\\Orders\\app-1.0.0\\orders.exe";

    // Runs the Electron-based application
    driver.getApplications().run(appPath);

    If your Electron application is distributed via installable binaries, several executables can be generated upon the installation. In order for the test engine to be able to access the application internals, use the application’s actual executable rather than the application launcher. Typically, the needed executable is located in the %APPDATA%\Local\<Your_App_Name>\app-N.N.N folder.

    To make sure that you use the proper executable, check the Path property of your Electron application process in the TestLeft UI Spy.

Specifics of Testing Electron Applications

  • TestLeft identifies applications created with Electron as the Process test objects rather than the Browser objects.

  • TestLeft recognizes the contents the Chromium web browser renders the same way it recognizes any other web application. Page objects correspond to rendered web pages. Child objects of the Page correspond to web elements on the page. WebView controls in your Electron applications are recognized as Frame objects.

Known Issues

  • If the script injection is restricted by Content Security Policy (CSP) in your tested Electron application, TestLeft will not be able to access internal objects of the application.

See Also

Identifying Web Objects
Preparing CEF-Based Applications for Testing

Highlight search results