try
{
var caps = new DesiredCapabilities();
var counter = 0;
while (proc != null && proc.MainWindowHandle.ToInt32() == 0 && counter < 30)
{
Thread.Sleep(500);
counter++;
}
var AppPath = @"C:\Windows\System32\notepad.exe";
caps.SetCapability("appTopLevelWindow", proc?.MainWindowHandle.ToInt64().ToString("x"));
caps.SetCapability("ms:experimental-webdriver", true);
caps.SetCapability("app", AppPath);
var urlWithPort = WinappServerUrl + selectedPort;
var url = new Uri(urlWithPort);
var driver = new WindowsDriver<WindowsElement>(url, caps, TimeSpan.FromMinutes(5));
Thread.Sleep(5000);
driver.Manage().Window.Maximize();
Thread.Sleep(1000);
return driver;
}
catch (Exception ex)
{
throw new Exception($"Failed in SetupWinAppDriver. Url={WinappServerUrl + selectedPort}, Exception = {ex}");
}
字符串
在上面的代码中,var driver = new WindowsDriver<WindowsElement>(url, caps, TimeSpan.FromMinutes(5));
这一行在Winappdriver和记事本成功启动后抛出。
错误为System.InvalidOperationException: 'An unknown error occurred in the remote end while processing the command.'
已尝试启用开发人员模式。已尝试在管理员模式下运行winappdriver。
1条答案
按热度按时间jm81lzqq1#
如果您想附加到现有流程,请尝试删除以下行:
字符串
如果您想运行应用程序并创建会话,请删除:
型