UI Automation for Wff CefSharp Browser Hosted in WPF Custom Controller

We have a WPF application in which we are using the CefSharp browser. The application has several wpf windows, inside which we embed the CefSharp browser control. The problem we are facing is about automation. We have already tried CUIT (Coded Ui Test) and Selenium - no one can identify the control inside the CefSharp browser. We can see that CUIT identifies the content of the CefSharp browser as an image. We also tried to expose the CefSharp automation tool from usercontrol, in which it is wrapped. However, we found that CefSharp does not provide any kind of automation for WPF - we fell back to zero when we tried to hijack automationpeer with the CefSharp browser. My question is, is automation possible for a CefSharp browser hosted inside a wpf control? If yes,then what should be the approach - any particular technology stack and / or any settings for the CefSharp browser? We are using VS 2015 for WPF application and CefSharp.Wpf 49.0.1

+3


source to share


1 answer


I solved the problem (CEF # Embedded automation in WPF application) by following these steps:

Determine the debug port in the .net application (at startup) that hosts the cef embedded web browser:

 var settings = new CefSettings { RemoteDebuggingPort = 8088 };
 Cef.Initialize(settings);

      



In Protractor (such as Selenium - another automation tool that is my favorite) config file, this full debug "ip: port" address should be specified by capability

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    specs: ['./tests.spec.js'],
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {'debuggerAddress': "127.0.0.1:8088" } 

// debugger Address : An address of a Chrome debugger server to connect to, in the form of <hostname/ip:port>, e.g. localhost:8088

}}

      

  • Launch .net app and enter screen with hosted web browser

  • Run protractor configuration.js (tests written in ./tests.spec.js will run for this)

+2


source







All Articles