Skip to content

Commit 8e91af9

Browse files
committed
Updating IE setAlertText command to check for invalid data
1 parent 1256dfe commit 8e91af9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

cpp/iedriver/CommandHandlers/SendKeysToAlertCommandHandler.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
3838
return;
3939
}
4040

41+
if (!text_parameter_iterator->second.isString()) {
42+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "text must be a string");
43+
return;
44+
}
45+
46+
std::string value = text_parameter_iterator->second.asString();
47+
4148
BrowserHandle browser_wrapper;
4249
int status_code = executor.GetCurrentBrowser(&browser_wrapper);
4350
if (status_code != WD_SUCCESS) {
@@ -51,14 +58,10 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
5158
response->SetErrorResponse(ERROR_NO_SUCH_ALERT, "No alert is active");
5259
} else {
5360
Alert dialog(browser_wrapper, alert_handle);
54-
if (text_parameter_iterator->second.isString()) {
55-
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "text must be a string");
56-
}
57-
std::string value = text_parameter_iterator->second.asString();
5861
status_code = dialog.SendKeys(value);
5962
if (status_code != WD_SUCCESS) {
60-
response->SetErrorResponse(status_code,
61-
"Modal dialog did not have a text box - maybe it was an alert");
63+
response->SetErrorResponse(ERROR_ELEMENT_NOT_INTERACTABLE,
64+
"Modal dialog did not have a text box - maybe it was an alert");
6265
return;
6366
}
6467
response->SetSuccessResponse(Json::Value::null);

0 commit comments

Comments
 (0)