unable to select file path from tree view with pywinauto

34 Views Asked by At

i am trying to run a .exe file with Python by using pywinauto package. i need to select a file path aa a part of this. i am able to access the button to select path and the tree view of folder structure is appearing. but when i pass the path to tree view warpper object it is saying the child dir is not there but it is actually there as can be seen in the image. what could be the issue and how to resolve it?

Here is the error message i am getting

IndexError: Item 'This PC' does not have a child 'OSDisk (C:)'

below is the code i am running

from pywinauto import Application
import time
import subprocess
import os


app = Application().start(r"path to my .exe file")

mainWindow = app.window(title = "MyApp")
browse_button = mainWindow.child_window(title="...", auto_id="setdirbutton", control_type="System.Windows.Forms.Button")
browse_button.click()

file_dialog = app.window(title="Browse For Folder")
file_dialog.wait("visible")

tree_view = file_dialog.child_window(title="Tree View", class_name="SysTreeView32")

wo = tree_view.wrapper_object()
wo.get_item('\Desktop\This PC\OSDisk (C:)').expand()

enter image description here

0

There are 0 best solutions below