Data Grid Interaction

Using Automa it is very easy to extract data from data tables such as WPF DataGrid.

# get the Kate's email address
>>> Text(below=Text("Email"), to_right_of=Text("Kate")).value
'kate@example.com'
 
# get the list of first 3 emails from the Email column
>>> emails = find_all(Text(below=Text("Email")))
>>> [e.value for e in sorted(emails, key=lambda email: email.y)[:3]]
[u'john19@gmail.com', u'd_brown@me.com', u'kate@example.com']
 
# get IDs of all members
>>> ids = find_all(Text(below="Id"))
>>> members = list()
>>> for id in ids:
...     is_member = CheckBox(to_right_of=id)
...     if is_member.is_checked():
...             members.append(int(id.value))
...
>>> members
[1, 2, 4, 5, 6, 9]