Commit ed3fbbd4 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS] Use a simpler grey matcher for web view

For some reason chrome_test_util::WebViewMatcher is flaky in these ones.
Could be related to the keyboard being in screen.

The flakiness appears to be related to iOS 13.4. Maybe a recent update
to the bots or a version upgrade of earl grey.

Using a simpler matcher seems to fix the issue.

Fixed: 1116043, 1116734, 1114899, 1111076, 1115321, 1111258, 1115282
Change-Id: I9172417a20d5b8e09dc47cd986256fc0a8cb46ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362892Reviewed-by: default avatarDavid Jean <djean@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799544}
parent f1d3e023
......@@ -44,9 +44,14 @@ BOOL WaitForKeyboardToAppear() {
return [waitForKeyboard waitWithTimeout:kWaitForActionTimeout];
}
// Returns a matcher for a web view.
id<GREYMatcher> WebViewMatcher() {
return grey_kindOfClass(NSClassFromString(@"WKWebView"));
}
} // namespace
// Integration Tests for Mannual Fallback Addresses View Controller.
// Integration Tests for Manual Fallback Addresses View Controller.
@interface AddressViewControllerTestCase : ChromeTestCase
@end
......@@ -69,17 +74,9 @@ BOOL WaitForKeyboardToAppear() {
}
// Tests that the addresses view controller appears on screen.
// TODO(crbug.com/1116274): Flaky on ios simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testAddressesViewControllerIsPresented \
DISABLED_testAddressesViewControllerIsPresented
#else
#define MAYBE_testAddressesViewControllerIsPresented \
testAddressesViewControllerIsPresented
#endif
- (void)MAYBE_testAddressesViewControllerIsPresented {
- (void)testAddressesViewControllerIsPresented {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -95,17 +92,9 @@ BOOL WaitForKeyboardToAppear() {
// Tests that the addresses view controller contains the "Manage Addresses..."
// action.
// TODO(crbug.com/1116043): Flaky on ios simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testAddressesViewControllerContainsManageAddressesAction \
DISABLED_testAddressesViewControllerContainsManageAddressesAction
#else
#define MAYBE_testAddressesViewControllerContainsManageAddressesAction \
testAddressesViewControllerContainsManageAddressesAction
#endif
- (void)MAYBE_testAddressesViewControllerContainsManageAddressesAction {
- (void)testAddressesViewControllerContainsManageAddressesAction {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -124,7 +113,7 @@ BOOL WaitForKeyboardToAppear() {
// Tests that the "Manage Addresses..." action works.
- (void)testManageAddressesActionOpensAddressSettings {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -146,17 +135,9 @@ BOOL WaitForKeyboardToAppear() {
// Tests that returning from "Manage Addresses..." leaves the icons and keyboard
// in the right state.
// TODO(crbug.com/1111076): Flaky on iOS simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testAddressesStateAfterPresentingManageAddresses \
DISABLED_testAddressesStateAfterPresentingManageAddresses
#else
#define MAYBE_testAddressesStateAfterPresentingManageAddresses \
testAddressesStateAfterPresentingManageAddresses
#endif
- (void)MAYBE_testAddressesStateAfterPresentingManageAddresses {
- (void)testAddressesStateAfterPresentingManageAddresses {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -211,7 +192,7 @@ BOOL WaitForKeyboardToAppear() {
;
}
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -238,20 +219,12 @@ BOOL WaitForKeyboardToAppear() {
// Tests that the Address View Controller is dismissed when tapping the outside
// the popover on iPad.
// TODO(crbug.com/1116887) Flaky on iOS simulator
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testIPadTappingOutsidePopOverDismissAddressController \
DISABLED_testIPadTappingOutsidePopOverDismissAddressController
#else
#define MAYBE_testIPadTappingOutsidePopOverDismissAddressController \
testIPadTappingOutsidePopOverDismissAddressController
#endif
- (void)MAYBE_testIPadTappingOutsidePopOverDismissAddressController {
- (void)testIPadTappingOutsidePopOverDismissAddressController {
if (![ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Test is not applicable for iPhone");
}
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the addresses icon.
......@@ -280,20 +253,12 @@ BOOL WaitForKeyboardToAppear() {
}
// Tests that the address icon is hidden when no addresses are available.
// TODO(crbug.com/1116043): Flaky on ios simulator.
#if TARGET_IPHONE_SIMULATOR
#define MAYBE_testAddressIconIsNotVisibleWhenAddressStoreEmpty \
DISABLED_testAddressIconIsNotVisibleWhenAddressStoreEmpty
#else
#define MAYBE_testAddressIconIsNotVisibleWhenAddressStoreEmpty \
testAddressIconIsNotVisibleWhenAddressStoreEmpty
#endif
- (void)MAYBE_testAddressIconIsNotVisibleWhenAddressStoreEmpty {
- (void)testAddressIconIsNotVisibleWhenAddressStoreEmpty {
// Delete the profile that is added on |-setUp|.
[AutofillAppInterface clearProfilesStore];
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Wait for the keyboard to appear.
......@@ -307,7 +272,7 @@ BOOL WaitForKeyboardToAppear() {
[AutofillAppInterface saveExampleProfile];
// Tap another field to trigger form activity.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Assert the address icon is visible now.
......
......@@ -48,6 +48,11 @@ id<GREYMatcher> ProfileTableViewButtonMatcher() {
return grey_buttonTitle(@"Underworld");
}
// Returns a matcher for a web view.
id<GREYMatcher> WebViewMatcher() {
return grey_kindOfClass(NSClassFromString(@"WKWebView"));
}
// Polls the JavaScript query |java_script_condition| until the returned
// |boolValue| is YES with a kWaitForActionTimeout timeout.
BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
......@@ -163,7 +168,7 @@ BOOL WaitForKeyboardToAppear() {
// will dismiss any.
if ([ChromeEarlGrey isIPadIdiom]) {
// Tap in the web view so the popover dismisses.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:grey_tapAtPoint(CGPointMake(0, 0))];
// Verify the table view is not visible.
......@@ -187,7 +192,7 @@ BOOL WaitForKeyboardToAppear() {
[AutofillAppInterface saveExampleProfile];
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Tap on the profiles icon.
......@@ -230,7 +235,7 @@ BOOL WaitForKeyboardToAppear() {
[AutofillAppInterface saveExampleProfile];
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Tap on the profiles icon.
......@@ -276,7 +281,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Tap on the profiles icon.
......@@ -301,7 +306,7 @@ BOOL WaitForKeyboardToAppear() {
// first.
if ([ChromeEarlGrey isIPadIdiom]) {
// Tap in the web view so the popover dismisses.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:grey_tapAtPoint(CGPointMake(0, 0))];
// Verify the table view is not visible.
......@@ -313,7 +318,7 @@ BOOL WaitForKeyboardToAppear() {
}
// Bring up the regular keyboard again.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Wait for the accessory icon to appear.
......@@ -344,7 +349,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
if (!UndockAndSplitKeyboard()) {
......@@ -389,7 +394,7 @@ BOOL WaitForKeyboardToAppear() {
assertWithMatcher:grey_nil()];
// Bring up the regular keyboard again.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementName)];
// Wait for the accessory icon to appear.
......@@ -420,7 +425,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
if (!UndockAndSplitKeyboard()) {
......@@ -449,14 +454,13 @@ BOOL WaitForKeyboardToAppear() {
}
// Tests that the manual fallback view is present in incognito.
// Disabled due to flakiness. See crbug.com/1115321.
- (void)DISABLED_testIncognitoManualFallbackMenu {
- (void)testIncognitoManualFallbackMenu {
// Add the profile to use for verification.
[AutofillAppInterface saveExampleProfile];
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -473,7 +477,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -486,13 +490,12 @@ BOOL WaitForKeyboardToAppear() {
// Tests the mediator stops observing objects when the incognito BVC is
// destroyed. Waiting for dealloc was causing a race condition with the
// autorelease pool, and some times a DCHECK will be hit.
// TODO(crbug.com/1111258): Investigate cause of flakiness and re-enable.
- (void)DISABLED_testOpeningIncognitoTabsDoNotLeak {
- (void)testOpeningIncognitoTabsDoNotLeak {
const GURL URL = self.testServer->GetURL(kFormHTMLFile);
std::string webViewText("Profile form");
[AutofillAppInterface saveExampleProfile];
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -506,7 +509,7 @@ BOOL WaitForKeyboardToAppear() {
[ChromeEarlGrey loadURL:URL];
[ChromeEarlGrey waitForWebStateContainingText:webViewText];
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -522,7 +525,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -538,7 +541,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Open a regular tab.
......@@ -548,7 +551,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// This will fail if there is more than one profiles icon in the hierarchy.
......@@ -559,14 +562,13 @@ BOOL WaitForKeyboardToAppear() {
}
// Tests that the manual fallback view is not duplicated after incognito.
// Disabled due to flakiness. See crbug.com/1115282.
- (void)DISABLED_testReturningFromIncognitoDoesNotDuplicatesManualFallbackMenu {
- (void)testReturningFromIncognitoDoesNotDuplicatesManualFallbackMenu {
// Add the profile to use for verification.
[AutofillAppInterface saveExampleProfile];
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Verify the profiles icon is visible.
......@@ -583,7 +585,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// Open a regular tab.
......@@ -593,7 +595,7 @@ BOOL WaitForKeyboardToAppear() {
// Bring up the keyboard by tapping the city, which is the element before the
// picker.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
[[EarlGrey selectElementWithMatcher:WebViewMatcher()]
performAction:chrome_test_util::TapWebElementWithId(kFormElementCity)];
// This will fail if there is more than one profiles icon in the hierarchy.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment