Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Question: How to use in a test #62

Open
evanblasband opened this issue Nov 4, 2021 · 2 comments
Open

Question: How to use in a test #62

evanblasband opened this issue Nov 4, 2021 · 2 comments

Comments

@evanblasband
Copy link

I have a questions on how to test this package in my app. Specifically I want to navigate to this page and run through different scenarios (i.e. enter correct pin, enter incorrect pin etc.) and verify the given action is correct. However I am not sure how to enter text into this widget for an input. I am currently doing the following:

      expect(findThisText('Please Enter Pin'), findsOneWidget);
      expect(findThisType(Image), findsOneWidget);
      expect(findThisKey(Key('kPinCodeTextField')), findsOneWidget);

      await tester.enterText(findThisKey(Key('kPinCodeTextField')), '111111');
      await tester.pump(Duration(seconds: 3));

where the key is for the PinCodeTextField widget in my app. Any insight would be much appreciated.

@gslender
Copy link

gslender commented May 2, 2022

Did you find any solutions? I'm thinking of swapping out this widget for something testable, as essentially it isn't that important / nice, and not being able to test-automate is seen as more important than fancy/styled pin code field

@gslender
Copy link

gslender commented May 2, 2022

This worked...

    await driver.runUnsynchronized(() async {
      final pinField = find.descendant(
        of: find.byType('PinCodeTextField'),
        matching: find.byType('AnimatedContainer'),
        firstMatchOnly: true,
      );
      await driver.tapElement(pinField);
      await driver.enterText('1234');
    });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants