Windows Application Driver handle windows explorer window

a 夏天 提交于 2020-01-06 08:57:30

问题


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.

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:


回答1:


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());

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.

Also take a look at these posts. Its about webdriver but the functions are similar:

webdriver C#

webdruver java



来源:https://stackoverflow.com/questions/55136005/windows-application-driver-handle-windows-explorer-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!