Commit 442ccdda authored by John Chen's avatar John Chen Committed by Commit Bot

[ChromeDriver] Increase reliability of launchApp

Fix launchApp command flakiness that has been observed in testing.

Bug: chromedriver:2607
Change-Id: I0db77d353079534238e857ffa090de0a37b52568
Reviewed-on: https://chromium-review.googlesource.com/c/1274589
Commit-Queue: John Chen <johnchen@chromium.org>
Reviewed-by: default avatarCaleb Rouleau <crouleau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#598794}
parent 34c9d33d
......@@ -176,6 +176,22 @@ Status ChromeDesktopImpl::GetAutomationExtension(
if (status.IsError())
return Status(kUnknownError, "cannot get automation extension", status);
// The automation extension page has been loaded, but it might not be
// initialized yet. Wait for up to 10 seconds for a function on the page
// to become defined, as a signal that the page is initialized.
base::TimeTicks deadline =
base::TimeTicks::Now() + base::TimeDelta::FromSeconds(10);
while (base::TimeTicks::Now() < deadline) {
std::unique_ptr<base::Value> result;
status = web_view->EvaluateScript(
std::string(), "typeof launchApp === 'function'", &result);
if (status.IsError())
return Status(kUnknownError, "cannot get automation extension", status);
if (result->is_bool() && result->GetBool())
break;
base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(50));
}
automation_extension_.reset(new AutomationExtension(std::move(web_view)));
}
*extension = automation_extension_.get();
......
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