winappdriver,appium,c#,连接到Windows 10上已经运行的窗口
我正在尝试使用C#.NET在Windows 10上使用WinapPdriver和Appium自动使用应用程序。
我正在尝试附加到已经运行的窗口上,但我一直找不到方法。我在网络上尝试了许多示例,包括从github网站for winappdriver。
https://github.com/microsoft/winappdriver 过程,但是当我尝试连接时,它会失败。它声称这不是顶级窗口。
具体错误是:“ openqa.selenium.webdriverexception:'b2c不是顶级窗口句柄'“
我已经尝试过“应用”条目,而不是“ apptoplevelwindow”,并且它不起作用。
这是我正在运行的代码:
private void grabWindowsProcesses2()
{
int number = 0;
_txtBxOutput.Text = "";
IntPtr myAppTopLevelWindowHandle = new IntPtr();
foreach (Process clsProcess in Process.GetProcesses())
{
number++;
_txtBxOutput.Text += number.ToString() + ") " + clsProcess.ProcessName + "\n";
if (clsProcess.ProcessName.Contains("VisualBoyAdvance"))
{
myAppTopLevelWindowHandle = clsProcess.Handle;
break;
}
}
var appTopLevelWindowHandleHex = myAppTopLevelWindowHandle.ToString("x");
AppiumOptions appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("platformName", "Windows");
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
appCapabilities.AddAdditionalCapability("appTopLevelWindow", appTopLevelWindowHandleHex);
/*
* Error I get here is: OpenQA.Selenium.WebDriverException: 'b2c is not a top level window handle'
*/
_visualBoyAdvance = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
}
有人对我做错了什么有任何想法吗?我是自动台式机的新手。我不知道,也许有更好的方法。
I'm trying to automate the use of an application with WinAppDriver and Appium on Windows 10 using C# .Net.
I'm trying to attach to an already running Window and I've been failing to find a way. I've tried many examples on the web, including from the github site for the WinAppDriver.
https://github.com/microsoft/WinAppDriver
I finally found a way to get a handle for the process, but when I try to connect it fails. It claims it's not a top level window.
The specific error is: "OpenQA.Selenium.WebDriverException: 'b2c is not a top level window handle'"
I've tried the "app" entry instead of "appTopLevelWindow", and it did not work.
Here is the code I'm running:
private void grabWindowsProcesses2()
{
int number = 0;
_txtBxOutput.Text = "";
IntPtr myAppTopLevelWindowHandle = new IntPtr();
foreach (Process clsProcess in Process.GetProcesses())
{
number++;
_txtBxOutput.Text += number.ToString() + ") " + clsProcess.ProcessName + "\n";
if (clsProcess.ProcessName.Contains("VisualBoyAdvance"))
{
myAppTopLevelWindowHandle = clsProcess.Handle;
break;
}
}
var appTopLevelWindowHandleHex = myAppTopLevelWindowHandle.ToString("x");
AppiumOptions appCapabilities = new AppiumOptions();
appCapabilities.AddAdditionalCapability("platformName", "Windows");
appCapabilities.AddAdditionalCapability("deviceName", "WindowsPC");
appCapabilities.AddAdditionalCapability("appTopLevelWindow", appTopLevelWindowHandleHex);
/*
* Error I get here is: OpenQA.Selenium.WebDriverException: 'b2c is not a top level window handle'
*/
_visualBoyAdvance = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);
}
Does anyone have any ideas about what I'm doing wrong? I'm fairly new to automating a desktop. I don't know, maybe there is a better way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论