From 69ea91bf61b10d2c31310ea1a2cb5fdda22c7267 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 30 Jun 2021 17:01:05 -0700 Subject: [PATCH] Wait for iOS UI buttons to exist before tapping (#85650) --- .../FlutterUITests/FlutterUITests.m | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dev/integration_tests/ios_host_app/FlutterUITests/FlutterUITests.m b/dev/integration_tests/ios_host_app/FlutterUITests/FlutterUITests.m index d52a1e5f1a..72f16bcfee 100644 --- a/dev/integration_tests/ios_host_app/FlutterUITests/FlutterUITests.m +++ b/dev/integration_tests/ios_host_app/FlutterUITests/FlutterUITests.m @@ -17,7 +17,9 @@ XCUIApplication *app = [[XCUIApplication alloc] init]; [app launch]; - [app.buttons[@"Full Screen (Cold)"] tap]; + XCUIElement *coldButton = app.buttons[@"Full Screen (Cold)"]; + XCTAssertTrue([coldButton waitForExistenceWithTimeout:60.0]); + [coldButton tap]; XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]); [app.otherElements[@"Increment via Flutter"] tap]; @@ -32,7 +34,9 @@ XCUIApplication *app = [[XCUIApplication alloc] init]; [app launch]; - [app.buttons[@"Full Screen (Warm)"] tap]; + XCUIElement *warmButton = app.buttons[@"Full Screen (Warm)"]; + XCTAssertTrue([warmButton waitForExistenceWithTimeout:60.0]); + [warmButton tap]; XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]); [app.otherElements[@"Increment via Flutter"] tap]; @@ -47,7 +51,9 @@ XCUIApplication *app = [[XCUIApplication alloc] init]; [app launch]; - [app.buttons[@"Flutter View (Warm)"] tap]; + XCUIElement *warmButton = app.buttons[@"Flutter View (Warm)"]; + XCTAssertTrue([warmButton waitForExistenceWithTimeout:60.0]); + [warmButton tap]; XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]); [app.otherElements[@"Increment via Flutter"] tap]; @@ -62,7 +68,9 @@ XCUIApplication *app = [[XCUIApplication alloc] init]; [app launch]; - [app.buttons[@"Hybrid View (Warm)"] tap]; + XCUIElement *warmButton = app.buttons[@"Hybrid View (Warm)"]; + XCTAssertTrue([warmButton waitForExistenceWithTimeout:60.0]); + [warmButton tap]; XCTAssertTrue([app.staticTexts[@"Flutter button tapped 0 times."] waitForExistenceWithTimeout:60.0]); XCTAssertTrue(app.staticTexts[@"Platform button tapped 0 times."].exists); @@ -87,8 +95,9 @@ [app.buttons[@"Dual Flutter View (Cold)"] tap]; // There are two marquees. - XCTAssertTrue([app.staticTexts[@"This is Marquee"] waitForExistenceWithTimeout:60.0]); - XCTAssertEqual([app.staticTexts matchingType:XCUIElementTypeStaticText identifier:@"This is Marquee"].count, 2); + XCUIElementQuery *marqueeQuery = [app.staticTexts matchingIdentifier:@"This is Marquee"]; + [self expectationForPredicate:[NSPredicate predicateWithFormat:@"count = 2"] evaluatedWithObject:marqueeQuery handler:nil]; + [self waitForExpectationsWithTimeout:30.0 handler:nil]; // Back navigation. [app.navigationBars[@"Dual Flutter Views"].buttons[@"Flutter iOS Demos Home"] tap];