Winappdriver: Support for Windows desktop apps like file explorer and device manager

Created on 17 Mar 2019  路  11Comments  路  Source: microsoft/WinAppDriver

I'm trying to upgrade firmware on my PC using windows UI automation. In the process, I wanted to go some file location in file explorer, right-click on inf file and then click on install button to install it. Later, go to device manager, click on firmware, device firmware and then on properties to see if the component properly working or not.
I did not find any WinAppDriver document that demonstrates this feature and I assumed this is not supported by WinAppDriver.

Is there any chance to support to handle Windows desktop apps like file explorer and device manager?

Most helpful comment

okay, thanks @timotiusmargo

All 11 comments

Hi @Vijayshanth,

We have a test scenario in Notepad Sample Test highlighting the ability to delete a file using File Explorer. In this test scenario, the script simply attempt to delete a saved file that was part of the test scenario as a clean up step.

Additionally, there are also few tests WebDriverAPI tests that uses File Explorer to demonstrate and validate certain API points such as:
https://github.com/Microsoft/WinAppDriver/blob/v1.1.1/Tests/WebDriverAPI/Back.cs
https://github.com/Microsoft/WinAppDriver/blob/v1.1.1/Tests/WebDriverAPI/Forward.cs

Hi @timotiusmargo

Thank you!

I've couple of questions here.

closing first question.
1. I'm writing test script in python. Do we have equivalent in Python for keys.Alt, keys.Enter, keys.Space and so on, which I found in the code base written in C#?
For example,

// Navigate Windows Explorer to change folder
session.Keyboard.SendKeys(Keys.Alt + "d" + Keys.Alt + CommonTestSettings.TestFolderLocation + Keys.Enter);

I'm trying to navigate to some folder location using Windows Explorer with following python code.

desired_caps['app'] = r"C:\Windows\System32\explorer.exe"
app = webdriver.Remote(command_executor='http://127.0.0.1:4723', desired_capabilities=desired_caps)
tool_bar = app.find_element_by_accessibility_id('1001').send_keys(r' C:\Dropbox\WinAppDriver\New folder')

Now, I need to press Enter key to go to the location and I did not find a right way to do this.

  1. I find it difficult to navigate over Windows device manager as locators which I was using to find UI elements were not correct despite taking the IDs from inspect.exe!
    for example, .find_element('Firmware').double_click() did not work.
    Can you please help me with the proper IDs to locate Firmware\`Device Firmware` on windows device manager?

About your first question, did you try the following ?
tool_bar.sendKeys(Keys.Enter);

There's PressKeyCode method exposed by the WindowsDriver as well, perhaps calling that on your app object will help.

Thank you, @naeemakram.

We need to import Keys class from selenium package.

from selenium.webdriver.common.keys import Keys
app.find_element_by_accessibility_id('1001').send_keys(r' C:\Dropbox\WinAppDriver\New folder' + Keys.ENTER)

Then we get access to special keys.

Yes, of course. Is there a restriction that you can't import the Keys class? Did it work?

Yes, it worked!

Wonderful. Can we close this issue?

may be this is not the right platform for questions. Please direct me to relevant discussion forum if you've any.

one last question before closing the issue.

do we have any means to control a pop-up window which is an output of a session?

For example, let's say we have opened a file explorer session using

desired_caps['app'] = r"C:\Windows\System32\explorer.exe"
app = webdriver.Remote(command_executor='http://127.0.0.1:4723', desired_capabilities=desired_caps)
app.find_element_by_accessibility_id........
.......

later we navigated to some folder, clicked on an executable file to install some software which yielded a pop-up window. At this point, we need to control a series of windows for set-up/install to complete.
How do we locate UI elements on these windows? Definitely, app.find_element_... won't work here as app would be referring to file explorer.

For question no. 2 in one of my comments, I'll try to figure out some way to deal with device manager.

Please close the issue.

Thank you for all your useful inputs and support!

A similar problem was fixed by another user in this thread given below. Visit it for full code. Important thing he said was
"After investigated the wiki documents, I can obtain the second form right now. To achieve this, need to hold a Desktop session, then find the second form from the desktop session, then attach to the second form."
https://github.com/Microsoft/WinAppDriver/issues/617

Hi @Vijayshanth,

As @naeemakram suggested, you can create a Desktop Session to navigate the entire desktop UI tree to locate the popup window/application window you are targeting. Once located, you can optionally create another new session specific to that window by attaching to it. This new session can now be used to automate the UI interactions to complete the installation experience.

okay, thanks @timotiusmargo

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bharathp666 picture bharathp666  路  3Comments

SimonKirkhamCL4U picture SimonKirkhamCL4U  路  3Comments

AmitVerma4HP picture AmitVerma4HP  路  3Comments

didhddldlq picture didhddldlq  路  3Comments

ant-skelia picture ant-skelia  路  4Comments