Windows应用程序驱动程序处理Windows资源管理器窗口 [英] Windows Application Driver handle windows explorer window
问题描述
我正在尝试使Windows桌面应用程序自动化,并且一切正常,直到在应用程序中的一个步骤中,我必须单击浏览"按钮才能打开Windows资源管理器窗口以选择图像并加载它
I'm trying to automate a windows desktop application and everything is fine until in one of the steps in my application, I have to click on a "Browse" buttom that opens a windows explorer window to select an image and load it.
问题是我不知道如何使WinAppDriver聚焦在这个新窗口中,以便能够选择图像并加载它.
The thing is that I do not know how to make WinAppDriver focus in this new window, to be able to select the image and load it.
这是桌面应用程序的一部分,在发送时单击浏览":
This is a part of the desktop application, and when sending click on Browse:
推荐答案
您可能需要winappdriver将其当前句柄从新的资源管理器窗口更改为一个.我不确定Python的语法,但是在C#中,您需要这样做:
You probably need winappdriver to change its current handle to the one from the new explorer window. I'm not sure about the Python syntax, but in C# you do it like this:
driver.SwitchTo().Window(Driver.WindowHandles.Last());
Last()
函数仅选择最近添加的windowHandle.
确保保持以前的窗口手柄不变,以便浏览器窗口关闭后可以切换回去.
The Last()
function just selects the most recent added windowHandle.
Make sure you keep your previous window handle around, so you can switch back once the explorer window closes.
也请看一下这些帖子.它与webdriver有关,但功能相似:
Also take a look at these posts. Its about webdriver but the functions are similar:
这篇关于Windows应用程序驱动程序处理Windows资源管理器窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!