'pywinauto automate Power BI Desktop tabs


I have Power BI Desktop *.pbix with a number of graphs.
Each graph is on a separate page.
Each "page" is represented as a tab labelled 'Page 1' 'Page 2' and 'Page 3'
I want pywinauto to click on each tab in turn so I can a picture of each graph as a image file *.png.
However pywinauto does not seem to be able to click on the page tab. This is the code which I've typed into python by hand so there is enough time to get the commands processed: >>from pywinauto.application import Application >>app = Application(backend="uia").start('pbidesktop.exe "C:\\temp\\powerBI\\Test3.pbix"') >>win = app.window(title_re = '.*Power BI Desktop') >>actionable_win = win.wait('visible') >>> app['Test3 - Power BI Desktop']['Page 2'] >>> app['Test3 - Power BI Desktop']['Page 2'].click_input()

When Power BI Desktop starts up it is on 'Page 3' and I'm expecting the code to get Power BI to go to 'Pgae 2' but it does not do so. Can anyone spot why the pywinauto does not go to tab 'Page 2'?

Also what is wrong with this code >>> actionable_win['Page 2'].click_input() Traceback (most recent call last): File "", line 1, in TypeError: 'UIAWrapper' object is not subscriptable Also what is wrong with this code >>> actionable_win['Tab->Page 2'].click_input() Traceback (most recent call last): File "", line 1, in TypeError: 'UIAWrapper' object is not subscriptable Thanks for any help



Solution 1:[1]

Thanks for all your feedback.

I found the answer.

Start Power BI application using test3.pbix as above.

I do the following to access the tabs in test3.pbix:

  1. I check to see if the tab exists eg. 'Page 2'
    win['Page 2'].wait('visible')
    You will get an exception from this command if the tab does not exist
  2. Select the tab
    win['Page 2'].click_input()

So I use variable win instead of actionable_win!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 phillip-from-oz