Skip to content

Commit 94678f7

Browse files
committed
Correcting invalid session ID response JSON payload for IE driver
1 parent 67b6c8d commit 94678f7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cpp/webdriver-server/server.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <cstring>
2020
#include <sstream>
2121
#include "session.h"
22+
#include "errorcodes.h"
2223
#include "uri_info.h"
2324
#include "logging.h"
2425

@@ -340,7 +341,8 @@ std::string Server::DispatchCommand(const std::string& uri,
340341

341342
if (command == webdriver::CommandType::NoCommand) {
342343
// Hand-code the response for an unknown URL
343-
serialized_response.append("{ \"error\" : \"unknown method\", ");
344+
serialized_response.append("{ \"value\" : { ");
345+
serialized_response.append("\"error\" : \"unknown method\", ");
344346
serialized_response.append("\"message\" : \"Command not found: ");
345347
serialized_response.append(http_verb);
346348
serialized_response.append(" ");
@@ -364,18 +366,23 @@ std::string Server::DispatchCommand(const std::string& uri,
364366
serialized_response.append("{ \"value\" : null }");
365367
} else {
366368
// Hand-code the response for an invalid session id
367-
serialized_response.append("{ \"error\" : \"invalid session id\", ");
369+
serialized_response.append("{ \"value\" : { ");
370+
serialized_response.append("\"error\" : \"");
371+
serialized_response.append(ERROR_INVALID_SESSION_ID).append("\", ");
368372
serialized_response.append("\"message\" : \"session ");
369373
serialized_response.append(session_id);
370-
serialized_response.append(" does not exist\" }");
374+
serialized_response.append(" does not exist\", ");
375+
serialized_response.append("\"stacktrace\" : \"\" }");
376+
serialized_response.append("}");
371377
}
372378
} else {
373379
if (command == webdriver::CommandType::NewSession &&
374380
this->sessions_.size() > 0) {
375381
// According to the W3C Specification, only a single session is
376382
// allowed by a single driver instance.
377383
serialized_response.append("{ \"value\" : { ");
378-
serialized_response.append("\"error\" : \"session not created\", ");
384+
serialized_response.append("\"error\" : \"");
385+
serialized_response.append(ERROR_SESSION_NOT_CREATED).append("\", ");
379386
serialized_response.append("\"message\" : \"only one session may ");
380387
serialized_response.append("be created at a time, and a session ");
381388
serialized_response.append("already exists\", ");

0 commit comments

Comments
 (0)