appium-flutter-driver icon indicating copy to clipboard operation
appium-flutter-driver copied to clipboard

Help determining checkbox widget state

Open AYASGray opened this issue 2 years ago • 1 comments

We have these Flutter checkboxes in our AUT, but I can't see any programmatic way from the appium-flutter-driver to be able to determine its checked property - any suggestions on how I could make that happen? Here's a screenshot from the widget inspector: Screenshot 2023-07-27 at 12 38 07 PM

AYASGray avatar Jul 27 '23 18:07 AYASGray

Hello! I've been facing with the same problem multiple times (retrieve state of element somehow) - and the solution was to expose something from widget's state to widget's ValueKey.

For example, you can add ValueKey('CheckboxIsChecked: $isChecked') to key of Checkbox widget. Then, in test - use waitFor method with finder byValueKey('CheckboxIsChecked: false') (for example).

If state correct - waitFor method passes. If not - fails with look up error.

I found it more efficient to query elements by ancestor and descendant finder, but this up to end developer.

Ernst-D avatar Jul 28 '23 08:07 Ernst-D