Reputation: 65
I am trying to automate Power BI report publishing to Power BI service. I found an inspiration here - https://github.com/dubravcik/pbixrefresher-python
Note: this is me first time ever using pywinauto
After clicking the publish button, you get prompted to choose a workspace to publish a report in. That's where the problem lies. I, for the world, cannot get pywinauto to click the desired workspace option from the ListBox. Below is the example of the list of workspaces to publish in.
Let us say, I want to click the 'c' option. ('a' is selected now) Now there is a lot things I've tried.The output of dialog.print_control_identifiers()
yields this structure below.
Current code looks like this:
app_instance = Application(backend = 'uia').connect(path = PROCNAME)
app_window = app_instance.window(title_re = ".*Power BI Desktop")
app_window.wait("enabled", timeout = 300)
app_window.Save.wait("enabled", timeout = 300)
app_window.set_focus()
# Publish
if True:
print("Publishing...")
app_window.Publish.click_input()
publish_dialog = app_window.child_window(auto_id = "KoPublishToGroupDialog")
publish_dialog.print_control_identifiers()
# publish_dialog.wait("enabled", timeout = 300)
# modalDialog = publish_dialog.child_window(auto_id = "modalDialog")
# modalDialog.wait("enabled", timeout = 300)
# dItem = modalDialog.child_window(title=WORKSPACE,control_type="DataItem")
# dItem.click_input()
According to the tree structure, I figured there was another dialog that might be "holding" the ListBox. However playing around with that didn't yield results. At this point, I really have no idea how to get Python to make that selection.
I will be eternally grateful for some help and advice. Thanks!
Upvotes: 1
Views: 1678
Reputation: 716
I see that no one has helped you yet. Maybe the tool I am developing could help you. It's a recording tool for Pywinauto. It records mouse and keyboard actions and generates a Python script. The generated Python script uses the functions of a simple API that overlays Pywinauto, the functions return Pywinauto wrappers.
Try it and tell me if it helped you. https://github.com/beuaaa/pywinauto_recorder
Upvotes: 0
Reputation: 49
this worked for me:
dash_reference = 'PBI_file_name_without_extention'
app = Application(backend='uia').connect(title=dash_reference+" - Power BI Desktop")
dlg = app[dash_simplifier + " - Power BI Desktop"]
dlg.child_window(title="My workspace", control_type="DataItem", found_index=0).click_input() #select my workspace and publish
dlg.Select.click()
Upvotes: 1