Preparing CEF-Based Applications for Testing

Applies to TestLeft 4.72, last modified on December 21, 2020

Before you can test CEF applications, you need to prepare it for testing.

Instrument CEF Application

TestLeft can automatically expose elements in CEF-based applications. To do this, launch your application from your tests while one of the following conditions is met:

  • The application’s executable imports the libcef.dll library.

— or —

  • The libcef.dll library and the application’s executable are located in the same folder.

— or —

  • The application has the injectCefHook command-line argument (in any letter case and with any prefix).

    C#

    using SmartBear.TestLeft;

    IProcess process = Driver.Applications.Run(@"C:\cefclient.exe", "-injectCefHook");

    Visual Basic .NET

    Imports SmartBear.TestLeft

    Dim process As IProcess = Driver.Applications.Run("C:\cefclient.exe", "-injectCefHook")

    Java

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

    TestProcess process = driver.getApplications().run("C:\\cefclient.exe", "-injectCefHook");

This is the recommended way to work with CEF-based applications.

Disable Windows (Off-Screen) Rendering

A CEF application can use windowed or windowless (off-screen) rendering. TestLeft supports CEF applications that use windowed rendering. Windowless (off-screen) rendering mode is supported only for WPF components of the CefSharp framework. Other applications that use windowless rendering are not supported. If your application uses windowless rendering, you need to disable it for testing purposes.

The way you disable windowless rendering depends on the programming language and framework used. Refer to the documentation of your CEF framework for details.

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

Known Issues

  • .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.

See Also

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

Highlight search results