Forum Discussion

sheetals's avatar
sheetals
Icon for Helper I rankHelper I
4 years ago

automation_id obtained is empty from Power BI desktop window components using RPA

I am trying to get all Power BI desktop components using rpaframework library from RPA.Desktop.Windows, but the automation_id returned is empty for most of the Power BI window components. Have shown result that below I get for few window components such as Close and Getdata.

([<uia_controls.StaticWrapper - 'Get data', Static, 8881667776078132027>,
<uia_controls.ButtonWrapper - 'Close', Button, -4781744411977329195>], [{'automation_id': '', 
'class_name': '', 'control_id': 'None', 'control_type': 'Text', 'enabled': 'True', 'handle': 
'None', 'name': 'Get data', 'parent': 'Button', 'process_id': '10844', 'rectangle': '(L195, T241, 
R255, B261)', 'rich_text': 'Get data', 'runtime_id': '(42, 133602, 4, 842, 61453, 1)', 'visible':
 'True', 'legacy': {'ChildId': 1, 'DefaultAction': '', 'Description': '', 'Help': '', 
'KeyboardShortcut': '', 'Name': 'Get data', 'Role': 42, 'State': 64, 'Value': ''}, 'object': 
<uia_controls.StaticWrapper - 'Get data', Static, 8881667776078132027>}, {'automation_id': '',
 'class_name': '', 'control_id': 'None', 'control_type': 'Button', 'enabled': 'True', 'handle': 
'None', 'name': 'Close', 'parent': 'Pane', 'process_id': '10844', 'rectangle': '(L1200, T73, 
R1232, B99)', 'rich_text': 'Close', 'runtime_id': '(42, 133602, 4, 855)', 'visible': 'True', 
'legacy': {'ChildId': 0, 'DefaultAction': 'Toggle', 'Description': '', 'Help': '', 
'KeyboardShortcut': '', 'Name': 'Close', 'Role': 43, 'State': 1048576, 'Value': ''}, 'object': 
<uia_controls.ButtonWrapper - 'Close', Button, -4781744411977329195>}])

I checked with Accessibility Insights For Windowsas well there it shows property does not exist value for key AutomationId as shown below. 

And because automation_id is empty I am accessing each power bi window element with key name and I get error in accessing elements because of this as raise ValueError(f"Could not find unique element for '{locator}'") ValueError: Could not find unique element for 'name:'Close' and control_type:Button'

Attaching the code below for Power BI desktop automation that I have tried using RPA

 

from RPA.Desktop.Windows import Windows
import time

win = Windows()
print(win)
def open_powerBI():
    win.open_from_search("PBIDesktop","Untitled - Power BI Desktop",120)
    time.sleep(10)
    first_window_elements = win.get_window_elements()
    print(first_window_elements)
    win.mouse_click("name:'Close' and control_type:Button")

if __name__ == "__main__":
    open_powerBI()

 

I have tried automation with Calculator app as well there I get automation_id value for all calculator app components as shown below and I am able to perform automation.

([<uia_controls.ButtonWrapper - 'Minus', Button, -1856622049320485851>, <uia_controls.ButtonWrapper - 'One', Button, 2312570849329984554>], [{'automation_id': 'minusButton', 'class_name': 'Button', 'control_id': 'None', 'control_type': 'Button', 'enabled': 'True', 'handle': 'None', 'name': 'Minus', 'parent': 'Group', 'process_id': '7528', 'rectangle': '(L754, T446, R830, B498)', 'rich_text': 'Minus', 'runtime_id': '(42, 197882, 4, 42)', 'visible': 'True', 'legacy': {'ChildId': 0, 'DefaultAction': 'Press', 'Description': '', 'Help': '', 'KeyboardShortcut': '', 'Name': 'Minus', 'Role': 43, 'State': 1048576, 'Value': ''}, 'object': <uia_controls.ButtonWrapper - 'Minus', Button, -1856622049320485851>},{'automation_id': 'num1Button', 'class_name': 'Button', 'control_id': 'None', 'control_type': 'Button', 'enabled': 'True', 'handle': 'None', 'name': 'One', 'parent': 'Group', 'process_id': '7528', 'rectangle': '(L519, T500, R595, B552)', 'rich_text': 'One', 'runtime_id': '(42, 197882, 4, 51)', 'visible': 'True', 'legacy': {'ChildId': 0, 'DefaultAction': 'Press', 'Description': '', 'Help': '', 'KeyboardShortcut': '', 'Name': 'One', 'Role': 43, 'State': 1048576, 'Value': ''}, 'object': <uia_controls.ButtonWrapper - 'One', Button, 2312570849329984554>}])

Any suggestion on why automation_id returned is empty for Power BI desktop and suggestions on why I am not able to access window components will be helpfull.