UI Automation using Selenium c# for Windows App developed with WPF application with CEF framework

UI Automation using Selenium c# for Windows App developed with WPF application with CEF framework

我正在尝试为使用 WPF 和 CEF(Chromium 嵌入式框架)制作的 Windows 应用程序执行 UI 自动化。 我在网上找不到很多关于这个主题的资料。

注意:尝试 UI 测试的应用程序已经 运行ning 在 windows 10 上,并且可以使用托盘图标将其最小化。

我想要完成的是 1. 打开应用程序 2. 在应用程序中搜索元素。 这是我为打开应用程序而编写的代码片段。

[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);
    }

当我运行这个时,我得到了错误

留言: 测试方法 WebViewPoc.UnitTest1.TestMethod1 抛出异常: OpenQA.Selenium.WebDriverException:未知错误:Chrome 启动失败:正常退出。 (未知错误:DevToolsActivePort 文件不存在) (从 chrome 位置 C:\Program Files (x86)\App\AppClient.exe 开始的进程不再是 运行ning,因此 ChromeDriver 假设 Chrome 已经坠毁。) 堆栈跟踪: RemoteWebDriver.UnpackAndThrowOnError(响应错误响应) RemoteWebDriver.Execute(字符串 driverCommandToExecute,Dictionary`2 参数) RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) RemoteWebDriver.ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) ChromeDriver.ctor(ChromeDriverService服务,ChromeOptions选项,TimeSpan commandTimeout) ChromeDriver.ctor(Chrome选项选项) UnitTest1.TestMethod1() 第 25 行

注意:我已经编辑了一些目录位置和名称。

如果有人可以帮助解决这个问题,并且如果有人之前已经自动化了这种应用程序,那将是很棒的,如果能为此获得一些代码,那就太好了。

[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#是你要测试的应用程序的调试端口号,这个可以问开发者。 询问开发人员是否还必须添加注册表项。