Commit b3ce1805 authored by Yiming Zhou's avatar Yiming Zhou Committed by Commit Bot

Use mouse click as a backup way to place focus in tests.

The Captured Sites Automation Framework interacts with real-world pages.
Some test actions, such as triggering autofill or typing password,
require the automation to place focus on page elements.

The framework currently invokes JavaScript's 'HtmlElement.focus()'
method to place focus on an element. However, it came to my attention
that this method occasionally fail on some test machines. This change
introduces mouse left click as a backup way to place focus on an
element, if JavaScript fails.

Fixed focus function in Capture Sites Test Framework.

The Captured Sites Test Framework uses JavaScript's .focus function to
place focus on a html element. This apparently fails from time to time
on some machines. This fix adds a left mouse click action to the element
if focus via script fails.

Bug: 847905
Change-Id: Idef08ac1e9adb225889d5da35d8f426bf4663f3e
Reviewed-on: https://chromium-review.googlesource.com/c/1332716Reviewed-by: default avatarSebastien Seguin-Gagnon <sebsg@chromium.org>
Commit-Queue: Yiming Zhou <uwyiming@google.com>
Cr-Commit-Position: refs/heads/master@{#608058}
parent 847e913a
......@@ -1358,9 +1358,13 @@ bool TestRecipeReplayer::PlaceFocusOnElement(content::RenderFrameHost* frame,
if (focused) {
return true;
} else {
ADD_FAILURE() << "Failed to place focus on the element: " << element_xpath
<< "!";
return false;
// Failing focusing on an element through script, use the less preferred
// method of left mouse clicking the element.
int x, y;
if (!GetCenterCoordinateOfTargetElement(frame, element_xpath, x, y))
return false;
return SimulateLeftMouseClickAt(frame, gfx::Point(x, y));
}
}
......
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