Limiting an instance of IEDriverServer.exe to a single session
This is a requirement of the W3C WebDriver Specification. To run multiple
sessions of IE, use multiple instances of IEDriverServer.exe.
@@ -369,6 +369,18 @@ std::string Server::DispatchCommand(const std::string& uri,
serialized_response.append(session_id);
serialized_response.append(" does not exist\" }");
}
+ } else {
+ if (command == webdriver::CommandType::NewSession &&
+ this->sessions_.size() > 0) {
+ // According to the W3C Specification, only a single session is
+ // allowed by a single driver instance.
+ serialized_response.append("{ \"value\" : { ");
+ serialized_response.append("\"error\" : \"session not created\", ");
+ serialized_response.append("\"message\" : \"only one session may ");
+ serialized_response.append("be created at a time, and a session ");
+ serialized_response.append("already exists\", ");
+ serialized_response.append("\"stacktrace\" : \"\" }");
+ serialized_response.append("}");
} else {
// Compile the serialized JSON representation of the command by hand.
std::string serialized_command = "{ \"name\" : \"" + command + "\"";
@@ -393,6 +405,7 @@ std::string Server::DispatchCommand(const std::string& uri,
}
}
}
+ }
LOG(DEBUG) << "Response: " << serialized_response;
return serialized_response;
}
