Skip to content

Commit e22cab5

Browse files
committed
Fixing IE driver setTimeouts command to properly validate JSON payload
1 parent a7c657e commit e22cab5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cpp/iedriver/CommandHandlers/SetTimeoutsCommandHandler.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,23 @@ void SetTimeoutsCommandHandler::ExecuteInternal(
3636
ParametersMap::const_iterator timeout_parameter_iterator = command_parameters.begin();
3737
for (; timeout_parameter_iterator != command_parameters.end(); ++timeout_parameter_iterator) {
3838
std::string timeout_type = timeout_parameter_iterator->first;
39+
if (timeout_type != "implicit" &&
40+
timeout_type != "script" &&
41+
timeout_type != "pageLoad") {
42+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
43+
return;
44+
}
45+
if (!timeout_parameter_iterator->second.isNumeric()) {
46+
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Timeout value for timeout type" + timeout_type + "must be an integer");
47+
return;
48+
}
3949
timeout = timeout_parameter_iterator->second.asUInt64();
4050
if (timeout_type == "implicit") {
4151
mutable_executor.set_implicit_wait_timeout(timeout);
4252
} else if (timeout_type == "script") {
4353
mutable_executor.set_async_script_timeout(timeout);
4454
} else if (timeout_type == "pageLoad") {
4555
mutable_executor.set_page_load_timeout(timeout);
46-
} else {
47-
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
48-
return;
4956
}
5057
}
5158
}

0 commit comments

Comments
 (0)