Created
April 29, 2020 09:00
-
-
Save ruan65/7986ab388a1a479e962cb153559db0a6 to your computer and use it in GitHub Desktop.
flutter autotest example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loginLogoutTest() { | |
group('app', () { | |
FlutterDriver driver; | |
setUpAll(() async { | |
driver = await FlutterDriver.connect(); | |
}); | |
tearDownAll(() async { | |
if (driver != null) { | |
driver.close(); | |
} | |
}); | |
test('check flutter driver health', () async { | |
Health health = await driver.checkHealth(); | |
print(health.status); | |
expect(health.status, HealthStatus.ok); | |
}); | |
test('Onboarding test', () async { | |
final SerializableFinder pager = | |
find.byValueKey(onboardingPageViewKeyValue); | |
await driver.waitFor(pager); | |
await driver.scroll(pager, -400, 0, Duration(milliseconds: 500)); | |
await driver.scroll(pager, -400, 0, Duration(milliseconds: 500)); | |
final nextButtonFinder = find.text('NEXT'); | |
await driver.tap(nextButtonFinder); | |
await Future.delayed(Duration(seconds: 1)); | |
await driver.runUnsynchronized(() async { | |
final SerializableFinder j2tEuButton = | |
find.byValueKey(j2tButtonKeyValue); | |
await driver.waitFor(j2tEuButton); | |
await driver.tap(j2tEuButton); | |
}); | |
}); | |
test('login j2tEu', () async { | |
final loginFinder = find.byValueKey(inputLoginKeyValue); | |
final pwdFinder = find.byValueKey(inputPwdKeyValue); | |
await driver.tap(loginFinder); | |
await driver.enterText(vikaLogin); | |
await driver.waitFor(find.text(vikaLogin)); | |
await Future.delayed(Duration(milliseconds: 300)); | |
await driver.tap(pwdFinder); | |
await driver.enterText(vikaPwd); | |
await driver.waitFor(find.text(vikaPwd)); | |
final submitFinder = find.text('Submit'); | |
await driver.waitFor(submitFinder); | |
await driver.tap(submitFinder); | |
await driver.waitFor( | |
find.text("Your account was\nsuccessfully linked to \nWonderWallet"), | |
timeout: Duration(seconds: 5)); | |
await Future.delayed(Duration(milliseconds: 300)); | |
final continueFinder = find.text('Continue'); | |
await driver.tap(continueFinder); | |
await driver.waitFor(find.text("Broker accounts Test"), | |
timeout: Duration(seconds: 10)); | |
await Future.delayed(Duration(milliseconds: 300)); | |
}); | |
test('logOut', () async { | |
await Future.delayed(Duration(milliseconds: 300)); | |
final logOutFinder = find.byValueKey(logoutIconKeyValue); | |
await driver.waitFor(logOutFinder); | |
await driver.tap(logOutFinder); | |
await Future.delayed(Duration(milliseconds: 600)); | |
final confirmLogOutFinder = find.byValueKey(confirmLogoutButtonKeyValue); | |
await driver.waitFor(confirmLogOutFinder); | |
await driver.tap(confirmLogOutFinder); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment