Commit cdd59ed6 authored by anandc's avatar anandc Committed by Commit bot

Wait for button to become active before clicking it.

BUG=411143

Review URL: https://codereview.chromium.org/544403002

Cr-Commit-Position: refs/heads/master@{#294092}
parent 37974aa8
......@@ -309,9 +309,8 @@ void RemoteDesktopBrowserTest::Approve() {
&RemoteDesktopBrowserTest::IsAuthenticatedInWindow,
browser()->tab_strip_model()->GetActiveWebContents()));
ExecuteScript(
"lso.approveButtonAction();"
"document.forms[\"connect-approve\"].submit();");
// Click to Approve the web-app.
ClickOnControl("submit_approve_access");
observer.Wait();
......@@ -708,6 +707,13 @@ void RemoteDesktopBrowserTest::RunJavaScriptTest(
void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) {
ASSERT_TRUE(HtmlElementVisible(name));
ConditionalTimeoutWaiter waiter(
base::TimeDelta::FromSeconds(5),
base::TimeDelta::FromMilliseconds(500),
base::Bind(&RemoteDesktopBrowserTest::IsEnabled,
active_web_contents(), name));
ASSERT_TRUE(waiter.Wait());
ExecuteScript("document.getElementById(\"" + name + "\").click();");
}
......@@ -801,4 +807,13 @@ bool RemoteDesktopBrowserTest::IsHostActionComplete(
host_action_var);
}
// static
bool RemoteDesktopBrowserTest::IsEnabled(
content::WebContents* client_web_content,
const std::string& element_name) {
return !ExecuteScriptAndExtractBool(
client_web_content,
"document.getElementById(\"" + element_name + "\").disabled");
}
} // namespace remoting
......@@ -314,6 +314,11 @@ class RemoteDesktopBrowserTest : public extensions::PlatformAppBrowserTest {
return IsAuthenticatedInWindow(active_web_contents());
}
// Callback used by Approve to check whether the Accept button is enabled
// and ready to receive a click.
static bool IsEnabled(
content::WebContents* web_contents, const std::string& name);
// If the "Host version out-of-date" form is visible, dismiss it.
void DismissHostVersionWarningIfVisible();
......
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