This definitely falls into the ‘reminding-myself-for-next-time’ blog category, but maybe this will help someone else out. I found myself needing to test radio buttons that didn’t have labels (don’t ask why). Those radio buttons all shared the same name attribute. Trying to access them by the name got the larger ListControl, not any of the radio buttons themselves:
>>> # here the radio buttons have the name "age_group" >>> from Products.Five.testbrowser import Browser >>> browser = Browser() >>> browser.getControl(name='age_group').click() >>> .... (continued) >>> AttributeError: 'ListControl' object has no attribute 'click'
You can, however, access the individual radio buttons from the ListControl using the controls attribute on the ListControl. controls returns a list of the ListControl’s child controls, which you can access by index.
>>> # here the second radio button's value attribute is '20-25' >>> browser.getControl(name='age_group').controls.selected = True >>> browser.getControl(name='age_group').value ['20-25']