MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / ListSessions

Method ListSessions

cpp/webdriver-server/server.cc:430–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430std::string Server::ListSessions() {
431 LOG(TRACE) << "Entering Server::ListSessions";
432
433 // Manually construct the serialized command for getting
434 // session capabilities.
435 std::string get_caps_command = "{ \"name\" : \"" +
436 webdriver::CommandType::GetSessionCapabilities
437 + "\"" +
438 ", \"locator\" : {}, \"parameters\" : {} }";
439
440 Json::Value sessions(Json::arrayValue);
441 SessionMap::iterator it = this->sessions_.begin();
442 for (; it != this->sessions_.end(); ++it) {
443 // Each element of the GetSessionList command is an object with two
444 // named properties, "id" and "capabilities". We already know the
445 // ID, so we execute the GetSessionCapabilities command on each session
446 // to be able to return the capabilities.
447 Json::Value session_descriptor;
448 session_descriptor["id"] = it->first;
449
450 SessionHandle session = it->second;
451 std::string serialized_session_response;
452 session->ExecuteCommand(get_caps_command, &serialized_session_response);
453
454 Response session_response;
455 session_response.Deserialize(serialized_session_response);
456 session_descriptor["capabilities"] = session_response.value();
457 sessions.append(session_descriptor);
458 }
459 Response response;
460 response.SetSuccessResponse(sessions);
461 return response.Serialize();
462}
463
464bool Server::LookupSession(const std::string& session_id,
465 SessionHandle* session_handle) {

Callers 1

DispatchCommandMethod · 0.95

Calls 8

endMethod · 0.80
ExecuteCommandMethod · 0.80
SetSuccessResponseMethod · 0.80
LOGClass · 0.70
DeserializeMethod · 0.45
valueMethod · 0.45
appendMethod · 0.45
SerializeMethod · 0.45

Tested by

no test coverage detected