Commit 630b62be authored by Eric Aleshire's avatar Eric Aleshire Committed by Commit Bot

Fix stability issues with Autofill automation tests.

1) I found in tapOnTarget, calling WebViewScrollElementToVisible then
WebViewTapElement is fragile for some reason. Debugging seems to hint
it's a race condition, where sometimes the window is not redrawn
(despite reporting that the new element is on screen), causing an
incorrect hitbox to be reported for the target element and misclicks
to occur.

Adding a 0.1s delay resolved those issues for me, and I will confirm it
is stable on waterfall after landing. It is a little clumsy, but think
it is plenty fine while investigating this further.

2) Not sure why, but target.getAttribute('placeholder') isn't working
for me anymore. After inspecting the HTML source for some target sites,
return target.placeholder; seemed to be a good fix.

Change-Id: Idf0bf0aca31578fc6ef0b18daa869cfba4b0160b
Reviewed-on: https://chromium-review.googlesource.com/c/1320751Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Commit-Queue: ericale <ericale@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606107}
parent 156c8830
......@@ -177,9 +177,20 @@ using web::test::ElementSelector;
// Wait for the element to be visible on the page.
[ChromeEarlGrey waitForWebViewContainingElement:selector];
// Potentially scroll into view if below the fold.
[[EarlGrey selectElementWithMatcher:web::WebViewInWebState(web_state)]
performAction:WebViewScrollElementToVisible(web_state, selector)];
// Calling WebViewTapElement right after WebViewScrollElement caused flaky
// issues with the wrong location being provided for the tap target,
// seemingly caused by the screen not redrawing in-between these two actions.
// We force a brief wait here to avoid this issue.
[[GREYCondition conditionWithName:@"forced wait to allow for redraw"
block:^BOOL {
return false;
}] waitWithTimeout:0.1];
// Tap on the element.
[[EarlGrey selectElementWithMatcher:web::WebViewInWebState(web_state)]
performAction:web::WebViewTapElement(web_state, selector)];
......@@ -356,7 +367,7 @@ using web::test::ElementSelector;
[self getStringFromDictionaryWithKey:"expectedValue"]);
NSString* predictionType = base::mac::ObjCCastStrict<NSString>([self
executeJavascript:"return target.getAttribute('placeholder');"
executeJavascript:"return target.placeholder;"
onTarget:[self selectorForTarget]]);
NSString* autofilledValue = base::mac::ObjCCastStrict<NSString>(
......
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