Search code examples
flutterflutter-test

How to find iOS back button programatically with FlutterDriver


I'm using FlutterDriver to perform integration testing for a Flutter package.

When the platform is Android, an AppBar is used in the scaffold, and when the platform is iOS, a CupertinoNavigationBar is used.

When testing on Android I can find the back button with the following code

await driver.tap(find.byTooltip('Back'));

However this fails on iOS. As the button is generated automatically I'm unable to add a tag programatically. Any suggestions for how to select it on iOS? Bonus points for cross-platform solutions.

Also, any suggestions for simulating an android-device back button tap (outside of the app)?


Solution

  • await driver.tap(find.pageBack());