Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: chrome/test/chromedriver/window_commands.cc

Issue 1827003004: [Chromedriver] Chromedriver should handle unexpected alert automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: make ignore value as default & fix nits. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/chromedriver/window_commands.cc
diff --git a/chrome/test/chromedriver/window_commands.cc b/chrome/test/chromedriver/window_commands.cc
index ac2598a6dba354b1b9fc0a03acb23ea73e2fd4e1..105211a48cae4a2335b403ec39259a23b7a9c7a1 100644
--- a/chrome/test/chromedriver/window_commands.cc
+++ b/chrome/test/chromedriver/window_commands.cc
@@ -224,6 +224,19 @@ Status ExecuteWindowCommand(const WindowCommand& command,
web_view->GetJavaScriptDialogManager()->GetDialogMessage(&alert_text);
if (status.IsError())
return status;
+
+ // Close the dialog depending on the unexpectedalert behaviour set by user
+ // before returning an error, so that subsequent commands do not fail.
+ std::string alert_behaviour = session->GetUnexpectedAlertBehaviour();
gmanikpure 2016/11/04 00:23:24 As discussed, directly putting it in session inste
+ if (alert_behaviour == Session::kAccept)
+ status = web_view->GetJavaScriptDialogManager()
+ ->HandleDialog(true, session->prompt_text.get());
+ else if (alert_behaviour == Session::kDismiss)
+ status = web_view->GetJavaScriptDialogManager()
+ ->HandleDialog(false, session->prompt_text.get());
+ if (status.IsError())
+ return status;
+
return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}");
}

Powered by Google App Engine
This is Rietveld 408576698