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() { ...@@ -309,9 +309,8 @@ void RemoteDesktopBrowserTest::Approve() {
&RemoteDesktopBrowserTest::IsAuthenticatedInWindow, &RemoteDesktopBrowserTest::IsAuthenticatedInWindow,
browser()->tab_strip_model()->GetActiveWebContents())); browser()->tab_strip_model()->GetActiveWebContents()));
ExecuteScript( // Click to Approve the web-app.
"lso.approveButtonAction();" ClickOnControl("submit_approve_access");
"document.forms[\"connect-approve\"].submit();");
observer.Wait(); observer.Wait();
...@@ -708,6 +707,13 @@ void RemoteDesktopBrowserTest::RunJavaScriptTest( ...@@ -708,6 +707,13 @@ void RemoteDesktopBrowserTest::RunJavaScriptTest(
void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) { void RemoteDesktopBrowserTest::ClickOnControl(const std::string& name) {
ASSERT_TRUE(HtmlElementVisible(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();"); ExecuteScript("document.getElementById(\"" + name + "\").click();");
} }
...@@ -801,4 +807,13 @@ bool RemoteDesktopBrowserTest::IsHostActionComplete( ...@@ -801,4 +807,13 @@ bool RemoteDesktopBrowserTest::IsHostActionComplete(
host_action_var); 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 } // namespace remoting
...@@ -314,6 +314,11 @@ class RemoteDesktopBrowserTest : public extensions::PlatformAppBrowserTest { ...@@ -314,6 +314,11 @@ class RemoteDesktopBrowserTest : public extensions::PlatformAppBrowserTest {
return IsAuthenticatedInWindow(active_web_contents()); 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. // If the "Host version out-of-date" form is visible, dismiss it.
void DismissHostVersionWarningIfVisible(); 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