Updating IE setAlertText command to check for invalid data
@@ -38,6 +38,13 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
return;
}
+ if (!text_parameter_iterator->second.isString()) {
+ response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "text must be a string");
+ return;
+ }
+
+ std::string value = text_parameter_iterator->second.asString();
+
BrowserHandle browser_wrapper;
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
if (status_code != WD_SUCCESS) {
@@ -51,13 +58,9 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
response->SetErrorResponse(ERROR_NO_SUCH_ALERT, "No alert is active");
} else {
Alert dialog(browser_wrapper, alert_handle);
- if (text_parameter_iterator->second.isString()) {
- response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "text must be a string");
- }
- std::string value = text_parameter_iterator->second.asString();
status_code = dialog.SendKeys(value);
if (status_code != WD_SUCCESS) {
- response->SetErrorResponse(status_code,
+ response->SetErrorResponse(ERROR_ELEMENT_NOT_INTERACTABLE,
"Modal dialog did not have a text box - maybe it was an alert");
return;
}
