python - How to right click on a folder and select from context menu using pywinauto? -
i'm writing automation tests cloud syncing desktop application. problem i'm facing cannot select sub-folder window , cannot select option context menu when right-click on folder.
example:
import pywinauto pywinauto.application().start(r'explorer.exe') explorer = pywinauto.application().connect(path='explorer.exe') newwindow = explorer.window_(top_level_only=true, active_only=true, class_name='cabinetwclass') newwindow.addressbandroot.clickinput() newwindow.typekeys(r'program files{enter}', with_spaces=true, set_foreground=false) programfiles = explorer.window_(top_level_only=true, active_only=true, title='program files', class_name='cabinetwclass') explorer.waitcpuusagelower(threshold=5) item = programfiles.folderview.getitem('7-zip') item.ensurevisible() item.rightclickinput()
response:
item = programfiles.folderview.getitem('7-zip') file "c:\python27\lib\site-packages\pywinauto\application.py", line 243, in __getattr__ ctrls = _resolve_control(self.criteria) file "c:\python27\lib\site-packages\pywinauto\application.py", line 758, in _resolve_control raise e.original_exception pywinauto.findbestmatch.matcherror: not find 'folderview' in '[u'', u'shellview', u'shellviewshelldll_defview', 'progress', u'uiribboncommandbar', u'24', u'25', u'20', u'21', u'22', u'23', u'workerw', u'0', u'scrollbar', u'4', u'8', 'treeview', u'directuihwnd', u'address band toolbartoolbar', u'shelldll_defview', u'namespace tree controlnamespacetreecontrol', u'universalsearchband', u'workerw1', u'workerw0', u'program filesshelltabwindowclass', u'tree viewtreeview', u'3', u'7', u'namespacetreecontrol', u'nuipane', u'search box', u'ctrlnotifysink0', u'ctrlnotifysink1', u'ctrlnotifysink2', u'ctrlnotifysink3', u'navigation buttons', u'program files', u'address band root', u'separatorband2', u'navigation buttonstoolbar', u'up band toolbartoolbar', u'workerw2', u'duiviewwndclassname', u'uiribboncommandbardock', u'namespace tree control', u'2', u'6', u'shelltabwindowclass', u'rebaraddress', 'toolbar3', u'ribbonuiribbonworkpane', u'toolbar1', u'toolbar0', 'toolbar5', 'toolbar4', u'up band toolbar', u'11', u'10', u'13', u'12', u'15', u'14', u'17', u'16', u'19', u'18', u'uiribbondocktopuiribboncommandbardock', u'uiribbondocktop', u'directuihwnd1', u'directuihwnd0', u'directuihwnd3', u'directuihwnd2', u'address: c:\\program filestoolbar', u'address: c:\\program files', u'breadcrumb parent', u'searcheditboxwrapperclass', u'upband', u'ctrlnotifysink', u'travelband', u'1', u'5', u'9', 'toolbar', 'rebar', u'netuihwnd', u'address band toolbar', u'separatorband0', u'separatorband1', u'ribbonuiribboncommandbar', u'ribbon2', u'ribbon1', u'ribbon0', 'toolbar2', u'tree view', u'uiribbonworkpane', u'rebar0', u'rebar1', 'rebar2', u'separatorband', u'ribbon']'
also, when on swapy, cannot find list sub-folders.
i have windows 10 x64, python 64bit. python , cmd running administrator. have tried on windows 7 x86 , x64 without success.
@vasily ryabov, can me example?
to continue vasiliy ryabov's answer. can accomplished latest uia branch of pywinauto. let's have video
folder opened , try right click on sub-folder called my home videos
. when context menu popped click on open
menu item:
dsk = pywinauto.desktop(backend='uia') explorer = pywinauto.application().connect(path='explorer.exe') # chain actions: set focus , right click after explorer.video.myhomevideos.set_focus().click_input(button='right') # here popup menu dsk.context.open.click_input()
Comments
Post a Comment