[英]UI Automation using Selenium c# for Windows App developed with WPF application with CEF framework
I am trying to do UI automation for a Windows app made with WPF and CEF(Chromium Embedded Framework).我正在尝试为使用 WPF 和 CEF(Chromium Embedded Framework)制作的 Windows 应用程序进行 UI 自动化。 I couldn't find much stuff online on this topic.
我在网上找不到很多关于这个主题的东西。
Note: The App trying to UI test is already running on windows 10 and it can be found minimized with the tray icons.注意:尝试 UI 测试的应用程序已经在 windows 10 上运行,并且可以通过托盘图标找到最小化。
What I am trying to accomplish is to 1. Open the app 2. Search for elements in the app.我想要完成的是 1. 打开应用程序 2. 在应用程序中搜索元素。 This is the code snippet i have written to open the app.
这是我为打开应用程序而编写的代码片段。
[TestMethod]
public void TestMethod1()
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.BinaryLocation = "C:\\Program Files (x86)\\App\\AppClient.exe";
System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", @"C:\Users\source\repos\bin\Debug\chromedriver.exe");
IWebDriver webDriver = new ChromeDriver(chromeOptions);
}
Message: Test method WebViewPoc.UnitTest1.TestMethod1 threw exception: OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited normally.消息:测试方法 WebViewPoc.UnitTest1.TestMethod1 抛出异常:OpenQA.Selenium.WebDriverException:未知错误:Chrome 无法启动:正常退出。 (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Program Files (x86)\App\AppClient.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Stack Trace: RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) ChromeDriver.ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) ChromeDriver.ctor(ChromeOptions options) UnitTest1.TestMethod1() line 25
(未知错误:DevToolsActivePort 文件不存在)(进程从 chrome 位置 C:\Program Files (x86)\App\AppClient.exe 不再运行,因此 ChromeDriver 假设 Chrome 已崩溃。)堆栈跟踪: RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 参数) RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) ChromeDriver.ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) ChromeDriver .ctor(ChromeOptions 选项) UnitTest1.TestMethod1() 第 25 行
Note: I have edited some of the dir location and names.注意:我已经编辑了一些目录位置和名称。
Will be great if someone could help with this and if someone has automated this kind of application before will be great to get some code for this.如果有人可以帮助解决这个问题,并且如果有人之前已经自动化了这种应用程序,将会很好地获得一些代码。
[TestMethod]
public void TestMethod1()
{
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.BinaryLocation = "C:\\Program Files (x86)\\App\\AppClient.exe";
chromeOptions.AddArguments("remote-debugging-port=port#");
var driver = new ChromeDriver(chromeOptions);
}
port# is debugging port number of the app you are trying to test, ask the developer for this. port#是您要测试的应用程序的调试端口号,请向开发人员询问。 Ask the developer if you have to add a registry key as well.
询问开发人员是否还必须添加注册表项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.