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

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: New modifications Created 4 years, 2 months 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..f6ac8615cb006b48617251002ade3e1c544c34dd 100644
--- a/chrome/test/chromedriver/window_commands.cc
+++ b/chrome/test/chromedriver/window_commands.cc
@@ -220,10 +220,23 @@ Status ExecuteWindowCommand(const WindowCommand& command,
if (web_view->GetJavaScriptDialogManager()->IsDialogOpen()) {
std::string alert_text;
+ std::string alert_behaviour = session->chrome->UnexpectedAlertBehaviour();
samuong 2016/11/02 22:48:48 nit: do this just before the if statement on line
gmanikpure 2016/11/04 00:23:24 Done.
status =
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.
+ if (alert_behaviour == "accept")
+ status = web_view->GetJavaScriptDialogManager()
+ ->HandleDialog(true, session->prompt_text.get());
+ else if (alert_behaviour == "dismiss")
+ status = web_view->GetJavaScriptDialogManager()
+ ->HandleDialog(false, session->prompt_text.get());
samuong 2016/11/02 22:48:48 does "ignore" mean "don't throw an error", or shou
gmanikpure 2016/11/04 00:23:24 As discussed, we will be throwing unexpected alert
+ if (status.IsError())
+ return status;
+
return Status(kUnexpectedAlertOpen, "{Alert text : " + alert_text + "}");
}

Powered by Google App Engine
This is Rietveld 408576698