Skip to content

Commit

Permalink
Fixing IE driver setTimeouts command to properly validate JSON payload
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Nov 28, 2017
1 parent a7c657e commit e22cab5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cpp/iedriver/CommandHandlers/SetTimeoutsCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,23 @@ void SetTimeoutsCommandHandler::ExecuteInternal(
ParametersMap::const_iterator timeout_parameter_iterator = command_parameters.begin();
for (; timeout_parameter_iterator != command_parameters.end(); ++timeout_parameter_iterator) {
std::string timeout_type = timeout_parameter_iterator->first;
if (timeout_type != "implicit" &&
timeout_type != "script" &&
timeout_type != "pageLoad") {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
return;
}
if (!timeout_parameter_iterator->second.isNumeric()) {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Timeout value for timeout type" + timeout_type + "must be an integer");
return;
}
timeout = timeout_parameter_iterator->second.asUInt64();
if (timeout_type == "implicit") {
mutable_executor.set_implicit_wait_timeout(timeout);
} else if (timeout_type == "script") {
mutable_executor.set_async_script_timeout(timeout);
} else if (timeout_type == "pageLoad") {
mutable_executor.set_page_load_timeout(timeout);
} else {
response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
return;
}
}
}
Expand Down

0 comments on commit e22cab5

Please sign in to comment.