簡體   English   中英

UI 自動化使用 Selenium c# 用於 Windows 應用程序開發使用 Z3055DD731D79EAA7189A62F36724EEF09 應用程序框架

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

我正在嘗試為使用 WPF 和 CEF(Chromium Embedded Framework)制作的 Windows 應用程序進行 UI 自動化。 我在網上找不到很多關於這個主題的東西。

注意:嘗試 UI 測試的應用程序已經在 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 不再運行,因此 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 行

注意:我已經編輯了一些目錄位置和名稱。

如果有人可以幫助解決這個問題,並且如果有人之前已經自動化了這種應用程序,將會很好地獲得一些代碼。

[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#是您要測試的應用程序的調試端口號,請向開發人員詢問。 詢問開發人員是否還必須添加注冊表項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM