WPF 用户控件中托管的 CefSharp Wpf 浏览器的 UI 自动化 [英] UI Automation for CefSharp Wpf browser hosted in WPF usercontrol

查看:77
本文介绍了WPF 用户控件中托管的 CefSharp Wpf 浏览器的 UI 自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 WPF 应用程序,我们使用 CefSharp 浏览器.该应用程序有一些 wpf 窗口,我们在其中嵌入了 CefSharp 浏览器控件.我们遇到的问题是关于自动化.我们已经尝试过 CUIT(编码 Ui 测试)和 Selenium - 没有一个能够识别 CefSharp 浏览器中的控件.我们看到 CUIT 将 CefSharp 浏览器内容识别为图像.我们还尝试从 CefSharp 中从包装它的用户控件中公开自动化对等体.但是我们发现,CefSharp 没有为 WPF 公开任何自动化对等体——当我们尝试从 CefSharp 浏览器控件中获取自动化对等体时,我们得到了 null.我的问题是 - 是否可以对 wpf 控件内托管的 CefSharp 浏览器进行自动化?如果是,那么应该采用什么方法 - 任何特定的技术堆栈和/或对 CefSharp 浏览器控件的任何调整?我们将 VS 2015 用于 WPF 应用程序和 CefSharp.Wpf 49.0.1

We have a WPF application where we are using CefSharp browser. The application has some wpf windows within which we are embedding the CefSharp browser control. The problem we have run into is regarding automation. We have tried CUIT(Coded Ui Test) and Selenium already - none is able to identify the control inside the CefSharp browser. We are seeing that CUIT is identifying the CefSharp browser content as an image. Also we tried to expose the automationpeer from CefSharp from the usercontrol in which it is wrapped. However we found that, CefSharp does not expose any automationpeer for WPF - we got back null when tried to grab automationpeer from CefSharp browser control. My question is - is it possible to do automation for a CefSharp browser that is hosted inside a wpf control? If yes, then what should be the approach - any specific technology stack and/or any tweaks to the CefSharp browser control? We are using VS 2015 for the WPF application and CefSharp.Wpf 49.0.1

推荐答案

我通过以下步骤解决了这个问题(Automating CEF# Embedded in a WPF application):

I have solved the problem(Automating CEF# Embedded in a WPF application) by taking the following steps:

在托管嵌入式 cef​​ 网络浏览器的 .net 应用程序(启动时)中定义调试端口:

Define debugging port in .net application (on start up) that hosts embedded cef web browser:

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

在 Protractor(它就像 Selenium——另一个自动化工具,这是我最喜欢的)配置文件中,这个完整的调试地址ip:port"应该在能力下定义

In Protractor(Its like Selenium – another automation tool, which is my favorite)  configuration file this full debugging address "ip:port" should be defined under capabilities

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

}}

  • 运行 .net 应用程序并使用托管的 Web 浏览器进入屏幕

    • Run .net application and enter the screen with the hosted web browser

      运行量角器 configuration.js(这将运行用 ./tests.spec.js 编写的测试)

      Run protractor configuration.js (This would run tests written in ./tests.spec.js)

      这篇关于WPF 用户控件中托管的 CefSharp Wpf 浏览器的 UI 自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆