Preparing CEF-Based Applications for Testing

Applies to TestLeft 15.40, last modified on March 17, 2022

This topic provides an overview of testing applications based on Chromium Embedded Framework (CEF).

Supported CEF Versions

Which CEF versions are supported depends on the approach to exposing CEF applications:

  • Chrome DevTools Protocol - CEF versions 88 (including minor versions) are supported.

    Note: We do not guarantee support for later CEF versions.
  • Script injection (legacy) - CEF versions 85.0.4183 and earlier are supported (except CEF3 1750).

    Note: For CEF applications that use WPF controls, only versions 84.0.04147 and earlier are supported.

Exposing CEF Applications

To simulate user actions over your CEF application, you expose web pages that the embedded Chromium web browser renders, in one of the following ways:

Via the Chrome DevTools Protocol (CDP)

The Chrome DevTools Protocol allows accessing and interacting with web applications running in Chromium-based web browsers. For TestLeft to be able to use the protocol to expose and test CEF applications, the application must be launched with the remote debugging port enabled and with the specified port that the test engine will listen to:

  • Launch the CEF application binary executable with the following command-line parameters:

    --remote-debugging-port=<port_number>

    Where port_number must belong to the 1024–65535 range and be available.

– or –

  • Use the ApplicationManager.Run method with the -cdpAutoSetPort command-line parameter specified. TestLeft will assign the remote debugging port and the port to listen to automatically:

    C#

    using SmartBear.TestLeft;


    string appPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    appPath += @"C:\cefclient.exe";

    // Runs the CEF-based application
    Driver.Applications.Run(appPath, "-cdpAutoSetPort");

    Visual Basic .NET

    Imports SmartBear.TestLeft

    Dim appPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
    appPath = appPath & "C:\cefclient.exe"

    ' Runs the CEF-based application Driver.Applications.Run(appPath, "-cdpAutoSetPort")

    Java

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


    String appPath = System.getenv("LOCALAPPDATA");
    appPath += "C:\\cefclient.exe";

    // Runs the CEF-based application
    driver.getApplications().run(appPath, "-cdpAutoSetPort");

Known issues and limitations

When you close your tested CEF application, it can exit unexpectedly.

Via script injection (Legacy)

This approach has been adopted in TestLeft versions prior to version 15.20. It has several limitations. We do not recommend that you use it.

Run your CEF application by using the ApplicationManager.Run method, with no extra command-line parameters:

C#

using SmartBear.TestLeft;


string appPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
appPath += @"C:\cefclient.exe";

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

Visual Basic .NET

Imports SmartBear.TestLeft

Dim appPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
appPath = appPath & "C:\cefclient.exe"

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

Java

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


String appPath = System.getenv("LOCALAPPDATA");
appPath += "C:\\cefclient.exe";

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

Known issues and limitations of the legacy CEF support
  • .NET applications created with CefGlue are not supported.

  • Windowless (offscreen) rendering mode is supported only for WPF controls of CefSharp applications. Other applications that use offscreeen rendering are not supported.

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

  • TestComplete cannot perform ClickItem actions on ListBox controls in applications based on CEF3 builds 1650 and 1750. This behavior is caused by an issue in the Chromium engine and was fixed in CEF build 1916. As a workaround, you can select items of ListBox controls by calling the Keys action:

    aListBox.Keys("[Down][Down]") // Select the second item in the list
    aListBox.Keys("myItem") // Input the desired value
  • If you face issues when accessing GUI objects in your CEF application, make sure the LifespanHandler and LoadHandler interfaces are implemented in your application.

Verify CEF Support

Start your tested application and examine it in the TestLeft UI Spy. The application’s object hierarchy must include a Page object.

Use the Page object to automate web pages and web page elements in the application’s embedded web browser.

CEF application in TestLeft UI Spy

See Also

Preparing Web Applications for Testing
Preparing Web Browsers for Testing
Preparing Electron Applications for Testing

Highlight search results