Cannot select item in ListBox

31 Views Asked by At

In Power BI, when I click in the "Publish" button, I have a screen with a ListBox. I want to select an specific item in this ListBox with the library pywinauto.

Currently, I already Open Power BI and click on the "Publish" button. I just cannot select the Workspace.

Control Identifiers:

Dialog - 'Publish to Power BI' (L341, T244, R939, B740)
['Publish to Power BI', 'Dialog', 'Publish to Power BIDialog', 'Publish to Power BI0', 'Publish to Power BI1']
child_window(title="Publish to Power BI", auto_id="KoPublishToGroupDialog", control_type="Window")
...
| | | | | | | | | | ListBox - '' (L373, T370, R909, B546)
| | | | | | | | | | ['My workspaceListBox', 'ListBox']
| | | | | | | | | | |
| | | | | | | | | | | DataItem - 'My workspace' (L373, T370, R892, B402)
| | | | | | | | | | | ['DataItem', 'My workspace', 'My workspaceDataItem', 'My workspace0', 'My workspace1', 'DataItem0', 'DataItem1']
| | | | | | | | | | | child_window(title="My workspace", control_type="DataItem")
| | | | | | | | | | | |
| | | | | | | | | | | | Static - 'My workspace' (L381, T370, R457, B402)
| | | | | | | | | | | | ['My workspace2', 'Static4', 'My workspaceStatic']
| | | | | | | | | | | | child_window(title="My workspace", control_type="Text")
| | | | | | | | | | |
...
| | | | | | | | | | |
| | | | | | | | | | | DataItem - 'Faros Migration' (L373, T466, R892, B498)
| | | | | | | | | | | ['Faros MigrationDataItem', 'DataItem4', 'Faros Migration', 'Faros Migration0', 'Faros Migration1']
| | | | | | | | | | | child_window(title="Faros Migration", control_type="DataItem")
| | | | | | | | | | | |
| | | | | | | | | | | | Static - 'Faros Migration' (L381, T466, R464, B498)
| | | | | | | | | | | | ['Faros Migration2', 'Static7', 'Faros MigrationStatic']
| | | | | | | | | | | | child_window(title="Faros Migration", control_type="Text")

I cannot select, click or do something similar in the element.

My current code:

import os
from pywinauto.application import Application
from pywinauto import timings
from time import sleep

PROCNAME = "PBIDesktop.exe"
WORKBOOK = "workbook.pbix"
WORKSPACE = "Faros Migration"
WAIT_TIMEOUT = 60

os.system('start "" "' + WORKBOOK + '"')
sleep(1)
app = Application(backend = 'uia').connect(path = PROCNAME)
win = app.window(title_re = '.*Power BI Desktop')
timings.after_clickinput_wait = 1

publish = win.child_window(title="Publish", control_type='Button', found_index=0).wait('visible', timeout=WAIT_TIMEOUT)
publish.click()

publish_dialog = win.child_window(auto_id = "KoPublishToGroupDialog")
publish_dialog.wait('visible', timeout = WAIT_TIMEOUT)

publish_dialog.ListBox[WORKSPACE].click()

AttributeError: 'ListItemWrapper' object has no attribute 'click'

I already tried to select(), invoke() and nothing works. I'm not able to use the element through publish_dialog.child_window(title="Faros Migration", control_type="DataItem") too.

0

There are 0 best solutions below