Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter integration test how to tap on camera button

Tags:

flutter

In flutter integration test, if we want to tap on a button that is built by ourselves, we can easily do it by:

await driver.tap(find.byValueKey("my_lovely_button_key"));

However, if a widget is not built by us, for example, a date picker, an image picker, etc., how do we tap on any of the buttons there?

like image 334
Yuchen Avatar asked Nov 07 '22 06:11

Yuchen


1 Answers

Regarding the date picker, what I found to be useful is that you can click on any button using:

await driver.tap(find.text('btn_name'));

For example, if you need the date 11 June 2020, you need to do these steps:

  1. await driver.tap(find.text('11'));
    
  2. await Future.delayed(const Duration(seconds: 1));
    
  3. await driver.tap(find.text('OK'));
    

What these steps will do is:

  1. Tap on button which has a text of "11",
  2. Wait for 1 second, and then
  3. Tap on the "OK" button.
like image 193
Andrew Arnita Avatar answered Dec 01 '22 00:12

Andrew Arnita