AndreHaueisen / flushbar

Custom widget for Flutter
Other
1.01k stars 172 forks source link

Impossible to get the Text elements by ValueKey pair #181

Closed cassioseffrin closed 3 years ago

cassioseffrin commented 3 years ago

The Issue It's impossible to get the element by ValueKey pair. We are using the appium-flutter-driver for mobile test automation. Using the ordinary snackbar I can get the element without any problem.

Snackbar

  scaffoldKey.currentState.showSnackBar(SnackBar(
    content: Text(text, key: Key('keyMessage')),
    behavior: SnackBarBehavior.fixed,
    duration: Duration(seconds: 3),
  ));

Flushbar

Flushbar(
    titleText: Text(
      "Attention",
      key: Key('keyTittle'),
    ),
    messageText: Text(
      "My text message",
      key: Key('keyMessage'),
    ),
    backgroundColor: isThemeDark(context) ? Colors.white : Colors.grey.shade800,
    progressIndicatorBackgroundColor: Colors.blueGrey,
    duration: Duration(milliseconds: 3000),
  )

Automation test with Java with appium-flutter-driver

public String obterMensagemFlushBar() {
    System.out.println("Obtendo a mensagem do SnackBar");
    entrarModoFLUTTER_APP();
     FlutterElement byValueKey = find.byValueKey("keyMessage");
    return(byValueKey.getText());
}

What I have tried I was unable to diagnose the problem. I suspect this is happening because the Flushbar widget tree is built on top of all screen elements. The main widget is a Stack. The Flushbar is an awesome option for all king of flutter apps, and It's also very important to do test automation, so I'll be grateful if anyone can help me with that.

Thanks in advance!

cassioseffrin commented 3 years ago

I managed to solve my problem by removing some effects like shouldIconPulse in the component flushbar. There are some issues in flushbar for appium-flutter-driver testing. I made a copy and customized it to resolve my situation. If anyone has the necessary needs, I can do a PR on this