1

I have a C++ application application.exe, which uses a CEF browser (chrome embedded framework) as the UI.

For this UI I want to develop automated tests with Selenium. Usually I control Selenium via Python.

I have worked with the chromedriver many times and developed browser tests. I do not quite understand how I can use it to control the CEF browser.

I have already found some pages here that contain the same topic. However, I still do not understand the interaction between Selenium and a CEF browser.

My goal is that Selenium starts application.exe so that I can control web elements within the CEF browser.

carapaece
  • 331
  • 4
  • 15

1 Answers1

2

You need to set setBinary in chromeoptions and provide the path of CEF browser .exe file.

Java Example code:

public class Example  {
  public static void main(String[] args) {
    // Path to the ChromeDriver executable.
    System.setProperty("webdriver.chrome.driver", "c:/temp/chromedriver.exe");

    ChromeOptions options = new ChromeOptions();
    // Path to the CEF executable.
    options.setBinary("c:/temp/cef_binary_3.2171.1979_windows32_client/Release/cefclient.exe");
    // Port to communicate on. Required starting with ChromeDriver v2.41.
    options.addArguments("remote-debugging-port=12345");

    WebDriver driver = new ChromeDriver(options);
    driver.get("http://www.google.com/xhtml");
    sleep(3000);  // Let the user actually see something!
    WebElement searchBox = driver.findElement(By.name("q"));
    searchBox.sendKeys("ChromeDriver");
    searchBox.submit();
    sleep(3000);  // Let the user actually see something!
    driver.quit();
  }

  static void sleep(int time) {
    try { Thread.sleep(time); } catch (InterruptedException e) {}
  }
}

Source:

https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md

https://www.ultimateqa.com/chromium-embedded-framework/

Note: You may need to use different version of chrome driver binary and chrome version dependencies in your project. identify the version which is compatible for your current version of CEF browser

Download link for Chrome driver binary:

https://chromedriver.storage.googleapis.com/index.html

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
  • So far so good. Unfortunately I get the following error message when starting the CEF application.exe: The file should implement the function void Start() for initializing the application and subscribing to all necessary events, such as the frame update. – carapaece Sep 06 '19 at 11:31
  • In addition, I have the following problem: `application.exe` is not the `CEF` process itself, but only starts it after data has been initialized. I'm not sure how to test this `CEF` process automatically. – carapaece Sep 06 '19 at 11:47
  • 1
    If it is desktop application then you can use winium or winappdriver(windows) it will trigger the application then you need to manage to store the cookie and pass to webdriver instance ... its an approach i never tried it myself – Shubham Jain Sep 06 '19 at 11:51
  • The error you are getting is because of the version of browser and you are using with dependencies you are using along with chromedriver as well... you need to find the matching version – Shubham Jain Sep 06 '19 at 11:56
  • 3. Download ChromeDriver from https://sites.google.com/a/chromium.org/chromedriver/downloads and extract (e.g. chromedriver_win32.zip provides chomedriver.exe). This tutorial was tested with version 2.14. 4. Download selenium-server-standalone-x.y.z.jar from http://selenium-release.storage.googleapis.com/index.html. This tutorial was tested with version 2.44.0. 5. Download a CEF binary distribution client from Downloads and extract (e.g. cef_binary_3.2171.1979_windows32_client.7z). – Shubham Jain Sep 06 '19 at 12:06
  • 1
    check the working and tested verison provided here: https://bitbucket.org/chromiumembedded/cef/wiki/UsingChromeDriver.md – Shubham Jain Sep 06 '19 at 12:07