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

Implement our own method to print finders #1353

Closed
jBorkowska opened this issue Jun 14, 2023 · 4 comments
Closed

Implement our own method to print finders #1353

jBorkowska opened this issue Jun 14, 2023 · 4 comments
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)

Comments

@jBorkowska
Copy link
Collaborator

The Flutter's one prints too many info

@bartekpacia
Copy link
Contributor

@fylyppo, you implemented a simple version of this last week. Can you post it here?

@bartekpacia bartekpacia added package: patrol Related to the patrol package (native automation, test bundling) feature New feature request labels Jun 20, 2023
@fylyppo
Copy link
Collaborator

fylyppo commented Jun 28, 2023

I have extended PatrolTester and NativeAutomator classes and then overridden methods I wanted to print from.
Short snippet:

class OwnPatrolTester extends PatrolTester {
  OwnPatrolTester({
    required PatrolTester patrolTester,
    required super.nativeAutomator,
    required super.config,
  }) : super(tester: patrolTester.tester);

  static const String phraseToSplitAt = ' (ignoring offstage widgets)';

  void logStep(String action, Finder finder, [String? additionalText]) {
    final finderTitleText = finder.toString().split(phraseToSplitAt).first;
    print('Runner: $action $finderTitleText ${additionalText ?? ''}');
  }

  void logTap(Finder finder) {
    logStep('Tapping', finder);
  }

  @override
  Future<void> tap(
    Finder finder, {
    bool? andSettle,
    Duration? visibleTimeout,
    Duration? settleTimeout,
  }) async {
    logTap(finder);
    await super.tap(
      finder,
      andSettle: andSettle,
      visibleTimeout: visibleTimeout,
      settleTimeout: settleTimeout,
    );
  }
}

I have added steps counter also.
The output from flutter logs I achieved:

I/flutter (21290): Runner step 0: Tapping exactly one widget with key [<'priceText'>] that has ancestor(s) with type "MenuListItem" which is an ancestor of text "Spinach Pizza" 
I/flutter (21290): Runner step 1: Waiting max 0:00:10.000000 until exactly one widget with key [<'priceText'>] that has ancestor(s) with type "MenuListItem" which is an ancestor of text "Spinach Pizza" is visible
I/flutter (21290): Runner step 2: Waiting max 0:00:10.000000 until exactly one widget with type "SnackBar" is visible
I/flutter (21290): Runner step 3: (native) Pressing Home  
I/flutter (21290): Runner step 4: (native) Opening App  
I/flutter (21290): Assert Soft expect failed: Expected: '$12.99 clicked wrong expect'
I/flutter (21290): Assert Soft expect succeeded: Expected: "$12.99 clicked" to be "$12.99 clicked"
I/flutter (21470): Runner step 0: Tapping exactly one widget with key [<'priceText'>] that has ancestor(s) with type "MenuListItem" which is an ancestor of text "Spinach Pizza" 
I/flutter (21470): Runner step 1: Waiting max 0:00:10.000000 until exactly one widget with key [<'priceText'>] that has ancestor(s) with type "MenuListItem" which is an ancestor of text "Spinach Pizza" is visible
I/flutter (21470): Runner step 2: Waiting max 0:00:10.000000 until exactly one widget with type "SnackBar" is visible
I/flutter (21470): Runner step 3: Entering text "text" into exactly one widget with key [<'key'>] 
I/flutter (21470): Runner step 4: Waiting max 0:00:10.000000 until exactly one widget with key [<'key'>] is visible

@jBorkowska
Copy link
Collaborator Author

Will be implemented as a part of #561, closing

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature request package: patrol Related to the patrol package (native automation, test bundling)
Projects
None yet
Development

No branches or pull requests

3 participants