问题
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