How to get text from Progress Dialog using Flutter Test Driver

669 views Asked by At

I have a Flutter Application. Currently I am trying to make an automated integration tests using Test Driver.

This is what I am trying to do.

Scenario:
- Click on Button
- Check if the Progress Dialog appeared

I was wondering if it is somehow possible to get the boolean value of the second step. I was trying to do methods like these:

Future<bool> loadingIndicatorVisible () async {
    var a = _driver.waitFor(find.byType("ProgressDialogType.Normal"));    
  }

but I was not able to do this with mentioned method.

This progress dialog has text "Loading...", but I was not able to do this with find.text either.

Is there any way to do this correctly?

1

There are 1 answers

0
Apuna12 On

This is something what helped me... I hope that someone in the future will see it useful

    isVisible(SerializableFinder finder, {duration = 1}) async {
    try {
      await _driver.waitFor(finder, timeout: Duration(seconds: duration));
      return true;
    } catch(exception) {
      return false;
    }
  }

And I used finder which looked like this:

final loadingIndicator = find.text("Loading...");

And of course this is method which I was calling out:

Future<bool> loadingIndicatorVisible () async {
    return await isVisible(loadingIndicator);
  }