`RPA.Windows` keyword `Get elements` not retrieving all elements
Keyword failed to retrieve all elements based on common locator. If you review the print tree, there are multiple RadioButtonControl types with the name "No" but the Get elements only returns one item.
KEYWORD win . Print Tree ${ANCHOR}
Documentation:
Print Control element tree.
Start / End / Elapsed: 20220913 16:10:10.173 / 20220913 16:10:10.679 / 00:00:00.506
16:10:10.175 TRACE Arguments: [ 'id:"individual-leftcontent"' ]
16:10:10.177 INFO Getting element with locator: id:"individual-leftcontent"
16:10:10.242 DEBUG argument root = None
16:10:10.244 DEBUG active anchor = None
16:10:10.253 DEBUG active window = ControlType: PaneControl ClassName: Chrome_WidgetWin_1 AutomationId: Rect: (708,328,2888,1698)[2180x1370] Name: 'EIN Individual Request - Online Application - Google Chrome' Handle: 0x7005FA(7341562)
16:10:10.259 DEBUG resulting root = ControlType: PaneControl ClassName: Chrome_WidgetWin_1 AutomationId: Rect: (708,328,2888,1698)[2180x1370] Name: 'EIN Individual Request - Online Application - Google Chrome' Handle: 0x7005FA(7341562)
16:10:10.259 INFO Root element: <uiautomation.uiautomation.PaneControl object at 0x0000021B64402760>
16:10:10.260 INFO Locator 'id:"individual-leftcontent"' produced matcher: MatchObject(locators=[('AutomationId', 'individual-leftcontent', 0)], _classes=set(), max_level=0)
16:10:10.422 INFO Returning element: WindowsElement(item=<uiautomation.uiautomation.GroupControl object at 0x0000021B55FEB610>, locator='id:"individual-leftcontent"', name='', automation_id='individual-leftcontent', control_type='GroupControl', class_name='', left=1235, right=2079, top=707, bottom=1345, width=844, height=638, xcenter=1657, ycenter=1026)
16:10:10.426 INFO ControlType: GroupControl ClassName: AutomationId: individual-leftcontent Rect: (1235,707,2079,1345)[844x638] Name: '' Handle: 0x0(0)
16:10:10.430 INFO ControlType: GroupControl ClassName: AutomationId: Rect: (1235,724,2079,1345)[844x621] Name: '' Handle: 0x0(0)
16:10:10.435 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1235,724,2079,749)[844x25] Name: 'Tell us more about the LLC.' Handle: 0x0(0)
16:10:10.443 INFO ControlType: GroupControl ClassName: AutomationId: Rect: (1235,766,2079,795)[844x29] Name: '' Handle: 0x0(0)
16:10:10.454 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1250,766,1260,794)[10x28] Name: '*' Handle: 0x0(0)
16:10:10.456 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1259,773,1384,792)[125x19] Name: ' Required fields' Handle: 0x0(0)
16:10:10.460 INFO ControlType: TableControl ClassName: AutomationId: Rect: (1314,794,2004,1199)[690x405] Name: '' Handle: 0x0(0)
16:10:10.466 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (1318,798,2000,874)[682x76] Name: '' Handle: 0x0(0)
16:10:10.472 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1318,798,1826,874)[508x76] Name: 'Does your business own a highway motor vehicle with a taxable gross weight of 55,000 pounds or more?*' Handle: 0x0(0)
16:10:10.476 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,813,1550,834)[217x21] Name: 'Does your business own a ' Handle: 0x0(0)
16:10:10.480 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1549,813,1728,834)[179x21] Name: 'highway motor vehicle' Handle: 0x0(0)
16:10:10.483 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1727,813,1780,834)[53x21] Name: ' with a' Handle: 0x0(0)
16:10:10.486 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (0,0,0,0)[0x0] Name: '\n' Handle: 0x0(0)
16:10:10.490 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1333,837,1498,858)[165x21] Name: 'taxable gross weight' Handle: 0x0(0)
16:10:10.492 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1497,837,1719,858)[222x21] Name: ' of 55,000 pounds or more?' Handle: 0x0(0)
16:10:10.495 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1726,831,1736,859)[10x28] Name: '*' Handle: 0x0(0)
16:10:10.501 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1829,798,2000,874)[171x76] Name: 'Yes \xa0Yes\xa0\xa0 No \xa0No' Handle: 0x0(0)
16:10:10.504 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioTrucking_y Rect: (1852,834,1872,854)[20x20] Name: 'Yes' Handle: 0x0(0)
16:10:10.507 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1876,837,1926,858)[50x21] Name: '\xa0Yes\xa0\xa0 ' Handle: 0x0(0)
16:10:10.509 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioTrucking_n Rect: (1932,834,1953,854)[21x20] Name: 'No' Handle: 0x0(0)
16:10:10.512 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1956,837,1985,858)[29x21] Name: '\xa0No' Handle: 0x0(0)
16:10:10.515 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (1318,877,2000,937)[682x60] Name: '' Handle: 0x0(0)
16:10:10.518 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1318,877,1826,937)[508x60] Name: 'Does your business involve gambling/wagering?*' Handle: 0x0(0)
16:10:10.521 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,898,1558,919)[225x21] Name: 'Does your business involve ' Handle: 0x0(0)
16:10:10.524 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1557,898,1709,919)[152x21] Name: 'gambling/wagering' Handle: 0x0(0)
16:10:10.526 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1708,898,1719,919)[11x21] Name: '?' Handle: 0x0(0)
16:10:10.530 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1726,892,1736,920)[10x28] Name: '*' Handle: 0x0(0)
16:10:10.533 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1829,877,2000,937)[171x60] Name: 'Yes \xa0Yes\xa0\xa0 No \xa0No' Handle: 0x0(0)
16:10:10.538 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioInvolveGambling_y Rect: (1852,897,1872,917)[20x20] Name: 'Yes' Handle: 0x0(0)
16:10:10.541 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1876,900,1926,921)[50x21] Name: '\xa0Yes\xa0\xa0 ' Handle: 0x0(0)
16:10:10.544 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioInvolveGambling_n Rect: (1932,897,1953,917)[21x20] Name: 'No' Handle: 0x0(0)
16:10:10.548 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1956,900,1985,921)[29x21] Name: '\xa0No' Handle: 0x0(0)
16:10:10.550 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (1318,940,2000,1016)[682x76] Name: '' Handle: 0x0(0)
16:10:10.554 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1318,940,1826,1016)[508x76] Name: 'Does your business need to file Form 720 (Quarterly Federal Excise Tax Return)?*' Handle: 0x0(0)
16:10:10.558 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,955,1590,976)[257x21] Name: 'Does your business need to file ' Handle: 0x0(0)
16:10:10.563 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1589,955,1667,976)[78x21] Name: 'Form 720' Handle: 0x0(0)
16:10:10.566 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (0,0,0,0)[0x0] Name: '\n' Handle: 0x0(0)
16:10:10.569 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,979,1485,1000)[152x21] Name: '(Quarterly Federal ' Handle: 0x0(0)
16:10:10.575 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1484,979,1630,1000)[146x21] Name: 'Excise Tax Return' Handle: 0x0(0)
16:10:10.579 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1629,979,1646,1000)[17x21] Name: ')?' Handle: 0x0(0)
16:10:10.582 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1652,973,1663,1001)[11x28] Name: '*' Handle: 0x0(0)
16:10:10.584 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1829,940,2000,1016)[171x76] Name: 'Yes \xa0Yes\xa0\xa0 No \xa0No' Handle: 0x0(0)
16:10:10.587 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioExciseTax_y Rect: (1852,976,1872,996)[20x20] Name: 'Yes' Handle: 0x0(0)
16:10:10.590 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1876,979,1926,1000)[50x21] Name: '\xa0Yes\xa0\xa0 ' Handle: 0x0(0)
16:10:10.593 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioExciseTax_n Rect: (1932,976,1953,996)[21x20] Name: 'No' Handle: 0x0(0)
16:10:10.596 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1956,979,1985,1000)[29x21] Name: '\xa0No' Handle: 0x0(0)
16:10:10.598 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (1318,1019,2000,1095)[682x76] Name: '' Handle: 0x0(0)
16:10:10.601 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1318,1019,1826,1095)[508x76] Name: 'Does your business sell or manufacture alcohol, tobacco, or firearms?*' Handle: 0x0(0)
16:10:10.603 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,1034,1811,1055)[478x21] Name: 'Does your business sell or manufacture alcohol, tobacco, or' Handle: 0x0(0)
16:10:10.606 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (0,0,0,0)[0x0] Name: '\n' Handle: 0x0(0)
16:10:10.609 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,1058,1409,1079)[76x21] Name: 'firearms?' Handle: 0x0(0)
16:10:10.612 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1416,1052,1426,1080)[10x28] Name: '*' Handle: 0x0(0)
16:10:10.615 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1829,1019,2000,1095)[171x76] Name: 'Yes \xa0Yes\xa0\xa0 No \xa0No' Handle: 0x0(0)
16:10:10.617 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioSellTobacco_y Rect: (1852,1055,1872,1075)[20x20] Name: 'Yes' Handle: 0x0(0)
16:10:10.620 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1876,1058,1926,1079)[50x21] Name: '\xa0Yes\xa0\xa0 ' Handle: 0x0(0)
16:10:10.622 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioSellTobacco_n Rect: (1932,1055,1953,1075)[21x20] Name: 'No' Handle: 0x0(0)
16:10:10.625 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1956,1058,1985,1079)[29x21] Name: '\xa0No' Handle: 0x0(0)
16:10:10.627 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (1318,1098,2000,1195)[682x97] Name: '' Handle: 0x0(0)
16:10:10.629 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1318,1098,1826,1195)[508x97] Name: 'Do you have, or do you expect to have, any employees who will receive Forms W-2 in the next 12 months?* (Forms W-2 require additional filings with the IRS.)' Handle: 0x0(0)
16:10:10.632 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,1113,1686,1134)[353x21] Name: 'Do you have, or do you expect to have, any ' Handle: 0x0(0)
16:10:10.635 INFO ControlType: HyperlinkControl ClassName: AutomationId: Rect: (1333,1113,1773,1158)[440x45] Name: 'employees who will receive Forms W-2' Handle: 0x0(0)
16:10:10.639 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1685,1113,1773,1134)[88x21] Name: 'employees' Handle: 0x0(0)
16:10:10.641 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (0,0,0,0)[0x0] Name: '\n' Handle: 0x0(0)
16:10:10.644 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,1137,1554,1158)[221x21] Name: 'who will receive Forms W-2' Handle: 0x0(0)
16:10:10.646 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1553,1137,1741,1158)[188x21] Name: ' in the next 12 months?' Handle: 0x0(0)
16:10:10.648 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1747,1131,1758,1159)[11x28] Name: '*' Handle: 0x0(0)
16:10:10.651 INFO ControlType: CustomControl ClassName: AutomationId: Rect: (0,0,0,0)[0x0] Name: '\n' Handle: 0x0(0)
16:10:10.654 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1333,1158,1736,1179)[403x21] Name: '(Forms W-2 require additional filings with the IRS.)' Handle: 0x0(0)
16:10:10.656 INFO ControlType: DataItemControl ClassName: AutomationId: Rect: (1829,1098,2000,1195)[171x97] Name: 'Yes \xa0Yes\xa0\xa0 No \xa0No' Handle: 0x0(0)
16:10:10.659 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioHasEmployees_y Rect: (1852,1136,1872,1157)[20x21] Name: 'Yes' Handle: 0x0(0)
16:10:10.661 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1876,1140,1926,1161)[50x21] Name: '\xa0Yes\xa0\xa0 ' Handle: 0x0(0)
16:10:10.663 INFO ControlType: RadioButtonControl ClassName: AutomationId: radioHasEmployees_n Rect: (1932,1136,1953,1157)[21x21] Name: 'No' Handle: 0x0(0)
16:10:10.666 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1956,1140,1985,1161)[29x21] Name: '\xa0No' Handle: 0x0(0)
16:10:10.668 INFO ControlType: GroupControl ClassName: AutomationId: Rect: (1235,1231,2079,1283)[844x52] Name: '' Handle: 0x0(0)
16:10:10.673 INFO ControlType: TextControl ClassName: AutomationId: Rect: (1385,1246,1865,1267)[480x21] Name: 'Before continuing, please review the information above.' Handle: 0x0(0)
16:10:10.675 INFO ControlType: GroupControl ClassName: AutomationId: Rect: (1235,1282,2079,1345)[844x63] Name: '' Handle: 0x0(0)
16:10:10.677 INFO ControlType: ButtonControl ClassName: AutomationId: Rect: (1835,1297,1968,1330)[133x33] Name: 'Continue >>' Handle: 0x0(0)
16:10:10.679 TRACE Return: None
00:00:00.079KEYWORD ${no_radios} = win . Get Elements ${ANCHOR} > type:RadioButtonControl and name:"No"
Documentation:
Get list of elements matching locator.
Start / End / Elapsed: 20220913 16:10:10.680 / 20220913 16:10:10.759 / 00:00:00.079
16:10:10.681 TRACE Arguments: [ 'id:"individual-leftcontent" > type:RadioButtonControl and name:"No"' ]
16:10:10.682 INFO Getting element with locator: id:"individual-leftcontent" > type:RadioButtonControl and name:"No"
16:10:10.683 DEBUG argument root = None
16:10:10.684 DEBUG active anchor = None
16:10:10.686 DEBUG active window = ControlType: PaneControl ClassName: Chrome_WidgetWin_1 AutomationId: Rect: (708,328,2888,1698)[2180x1370] Name: 'EIN Individual Request - Online Application - Google Chrome' Handle: 0x7005FA(7341562)
16:10:10.687 DEBUG resulting root = ControlType: PaneControl ClassName: Chrome_WidgetWin_1 AutomationId: Rect: (708,328,2888,1698)[2180x1370] Name: 'EIN Individual Request - Online Application - Google Chrome' Handle: 0x7005FA(7341562)
16:10:10.687 INFO Root element: <uiautomation.uiautomation.PaneControl object at 0x0000021B64402760>
16:10:10.688 INFO Locator 'id:"individual-leftcontent"' produced matcher: MatchObject(locators=[('AutomationId', 'individual-leftcontent', 0)], _classes=set(), max_level=0)
16:10:10.732 INFO Root element: <uiautomation.uiautomation.GroupControl object at 0x0000021B55FEB4C0>
16:10:10.732 INFO Locator 'type:RadioButtonControl and name:"No"' produced matcher: MatchObject(locators=[('ControlType', 'RadioButtonControl', 0), ('Name', 'No', 0)], _classes=set(), max_level=0)
16:10:10.755 INFO Returning element: WindowsElement(item=<uiautomation.uiautomation.RadioButtonControl object at 0x0000021B55FEB580>, locator='id:"individual-leftcontent" > type:RadioButtonControl and name:"No"', name='No', automation_id='radioTrucking_n', control_type='RadioButtonControl', class_name='', left=1932, right=1953, top=834, bottom=854, width=21, height=20, xcenter=1942, ycenter=844)
16:10:10.758 TRACE Return: [WindowsElement(item=<uiautomation.uiautomation.RadioButtonControl object at 0x0000021B55FEB580>, locator='id:"individual-leftcontent" > type:RadioButtonControl and name:"No"', name='No', automation_id='radioTrucking_n', control_type='RadioButtonControl', class_name='', left=1932, right=1953, top=834, bottom=854, width=21, height=20, xcenter=1942, ycenter=844)]
16:10:10.759 INFO ${no_radios} = [WindowsElement(item=<uiautomation.uiautomation.RadioButtonControl object at 0x0000021B55FEB580>, locator='id:"individual-leftcontent" > type:RadioButtonControl and name:"No"', name='No', automation_i...
00:00:00.001KEYWORD BuiltIn . Log Many @{no_radios}
Documentation:
Logs the given messages as separate entries using the INFO level.
Start / End / Elapsed: 20220913 16:10:10.760 / 20220913 16:10:10.761 / 00:00:00.001
16:10:10.760 TRACE Arguments: [ '@{no_radios}' ]
16:10:10.761 INFO WindowsElement(item=<uiautomation.uiautomation.RadioButtonControl object at 0x0000021B55FEB580>, locator='id:"individual-leftcontent" > type:RadioButtonControl and name:"No"', name='No', automation_id='radioTrucking_n', control_type='RadioButtonControl', class_name='', left=1932, right=1953, top=834, bottom=854, width=21, height=20, xcenter=1942, ycenter=844)
16:10:10.761 TRACE Return: None
I tried to increase the depth on the Get elements keyword to 16, but it still only found the first radio button.
This is the piece of code that produced those log entries:
win.Print tree ${ANCHOR}
${no_radios}= win.Get elements ${ANCHOR} > type:RadioButtonControl and name:"No" and depth:16
Log many @{no_radios}
FOR ${radio} IN @{no_radios}
win.Click ${radio}
END
To add in the context, our Get Elements uses the idea of siblings (sister elements on the same level with the one identified), so that's why is finding only one element, because there's only one matching the locator on the same tree level.
Maybe we should come up with a new keyword (like Get All Elements) which will look into the entire tree, not just over a list of returned siblings on the level of the first found match. @mikahanninen
Well, intuitively, I figured Get elements would already get all elements under the anchor I gave it.
I discussed this with @mikahanninen on a call today and we are thinking an extra parameter on Get elements should suffice. I was thinking that changing the default behavior would be preferable, but it might be a breaking change if people rely on it to be only the one branch of the tree.