@@ -38,6 +38,13 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
38
38
return ;
39
39
}
40
40
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
+
41
48
BrowserHandle browser_wrapper;
42
49
int status_code = executor.GetCurrentBrowser (&browser_wrapper);
43
50
if (status_code != WD_SUCCESS) {
@@ -51,14 +58,10 @@ void SendKeysToAlertCommandHandler::ExecuteInternal(
51
58
response->SetErrorResponse (ERROR_NO_SUCH_ALERT, " No alert is active" );
52
59
} else {
53
60
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 ();
58
61
status_code = dialog.SendKeys (value);
59
62
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" );
62
65
return ;
63
66
}
64
67
response->SetSuccessResponse (Json::Value::null);
0 commit comments