Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter_driver's finders should have the equivalent of flutter_test's Finder.evaluate() #15852

Open
deonchimple opened this issue Mar 23, 2018 · 8 comments
Labels
a: tests "flutter test", flutter_test, or one of our tests c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project t: flutter driver "flutter driver", flutter_drive, or a driver test team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@deonchimple
Copy link

deonchimple commented Mar 23, 2018

Steps to Reproduce

Using flutter_driver in the QA environment. Options feels quite limited currently. I am trying to check if an element exists or not, perhaps a function on the like of finder.IsEmpty or something like IfExists in Appium which the skips the element if it doesn't exist and doesn't necessarily throw an exception.

Logs

Application runs fine. Just looking for more functionalities of flutter driver.

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.1.5, on Microsoft Windows [Version 6.1.7601], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[!] Android Studio (version 2.3)
    X Unable to find bundled Java version.
[√] Android Studio (version 3.0)
[√] VS Code (version 1.21.1)
[√] Connected devices (1 available)

! Doctor found issues in 1 category.
@deonchimple deonchimple changed the title To check if an element exists or to skip it if the element doesn't exist using flutter drive To check if an element exists or to skip it if the element doesn't exist using flutter_driver(QA environment) Mar 23, 2018
@zoechi
Copy link
Contributor

zoechi commented Mar 23, 2018

@deonchimple
Copy link
Author

@zoechi Unfortunately all this does is wait for the element but doesn't necessarily check if the element is visible/ present (Ideally returning a boolean value).

For instance when I am searching for an element, I would like to give a condition which would go to the next element if the current element isn't found. This requires a boolean function like Ispresent, IsEmpty, isVisible available in Appium and selenium.

@zoechi zoechi added the a: tests "flutter test", flutter_test, or one of our tests label Jul 6, 2018
@jonsamwell
Copy link

jonsamwell commented Oct 17, 2018

@deonchimple can you not assume that if the wait times out that the element is not in the widget tree? If so you could do something like this.

  Future<void> testStep() async {
    final isOpen = await isPresent(find.byType("Drawer"), driver);
    if (isOpen) {
      ...
    }
  }

  Future<bool> isPresent(SerializableFinder finder, FlutterDriver driver, {Duration timeout = const Duration(seconds: 1)}) async {
    try {
      await driver.waitFor(finder, timeout: timeout);
      return true;
    } catch (e) {
      return false;
    }
  }

@brianegan
Copy link
Contributor

brianegan commented Feb 13, 2019

@jonsamwell Yep! I've been doing something almost exactly like that and it generally works, but I agree
with the original author that it would be great if that was a method that already existed, since i can imagine a lot of us have that same code in our code bases :)

@zoechi zoechi added tool Affects the "flutter" command-line tool. See also t: labels. t: flutter driver "flutter driver", flutter_drive, or a driver test labels Feb 13, 2019
@zoechi zoechi added this to the Goals milestone Feb 13, 2019
@akaGelo
Copy link

akaGelo commented Oct 23, 2019

Future<void> waitForAbsent(SerializableFinder finder, { Duration timeout }) async {

      await driver.waitForAbsent(loginButton);

@Hixie
Copy link
Contributor

Hixie commented Jan 10, 2020

Being able to do the equivalent of "Finder.evaluate()" in a driver test would make sense.

@Hixie Hixie modified the milestones: Goals, Future Jan 10, 2020
@Hixie Hixie changed the title To check if an element exists or to skip it if the element doesn't exist using flutter_driver(QA environment) flutter_driver's finders should have the equivalent of flutter_test's Finder.evaluate() Jan 10, 2020
@jonahwilliams jonahwilliams removed the tool Affects the "flutter" command-line tool. See also t: labels. label Jan 10, 2020
@iapicca iapicca added passed first triage c: proposal A detailed proposal for a change to Flutter c: new feature Nothing broken; request for a new capability labels Jan 14, 2020
@dnfield dnfield added the framework flutter/packages/flutter repository. See also f: labels. label Jan 15, 2020
@kf6gpe kf6gpe added the P6 label May 29, 2020
@kf6gpe kf6gpe removed this from the Future milestone Jun 1, 2020
@kutlaykural
Copy link

But using that function;

Future<bool> isPresent(SerializableFinder finder, FlutterDriver driver, {Duration timeout = const Duration(seconds: 1)}) async {
    try {
      await driver.waitFor(finder, timeout: timeout);
      return true;
    } catch (e) {
      return false;
    }
  }

causes an error log like that
VMServiceFlutterDriver: waitFor message is taking a long time to complete...
is there a way to get rid of that error message?

@Akkasim46
Copy link

FlutterDriver does not exist in Flutter 2.5....
So we can use the above method.
any substitute for that method with WidgetTester?

@flutter-triage-bot flutter-triage-bot bot added P3 Issues that are less important to the Flutter project and removed P6 labels Jun 28, 2023
@flutter-triage-bot flutter-triage-bot bot added the team-framework Owned by Framework team label Jul 8, 2023
@flutter-triage-bot flutter-triage-bot bot added the triaged-framework Triaged by Framework team label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: tests "flutter test", flutter_test, or one of our tests c: new feature Nothing broken; request for a new capability c: proposal A detailed proposal for a change to Flutter framework flutter/packages/flutter repository. See also f: labels. P3 Issues that are less important to the Flutter project t: flutter driver "flutter driver", flutter_drive, or a driver test team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

No branches or pull requests