diff options
Diffstat (limited to 'chrome/test/webdriver/commands/create_session.cc')
-rw-r--r-- | chrome/test/webdriver/commands/create_session.cc | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/chrome/test/webdriver/commands/create_session.cc b/chrome/test/webdriver/commands/create_session.cc index 73bb97d..5c9e95b 100644 --- a/chrome/test/webdriver/commands/create_session.cc +++ b/chrome/test/webdriver/commands/create_session.cc @@ -8,6 +8,7 @@ #include <string> #include "base/file_path.h" +#include "base/stringprintf.h" #include "base/values.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/common/chrome_constants.h" @@ -17,6 +18,9 @@ namespace webdriver { +// The minimum supported version of Chrome for this version of ChromeDriver. +const int kMinSupportedChromeVersion = 12; + CreateSession::CreateSession(const std::vector<std::string>& path_segments, const DictionaryValue* const parameters) : Command(path_segments, parameters) {} @@ -30,10 +34,33 @@ void CreateSession::ExecutePost(Response* const response) { // Session manages its own liftime, so do not call delete. Session* session = new Session(); - if (!session->Init(session_manager->chrome_dir())) { + ErrorCode code = session->Init(session_manager->chrome_dir()); + + if (code == kBrowserCouldNotBeFound) { SET_WEBDRIVER_ERROR(response, - "Failed to initialize session", - kInternalServerError); + "Chrome could not be found.", + kUnknownError); + return; + } else if (code == kBrowserFailedToStart) { + std::string error_msg = base::StringPrintf( + "Chrome could not be started successfully. " + "Please update ChromeDriver and ensure you are using Chrome %d+.", + kMinSupportedChromeVersion); + SET_WEBDRIVER_ERROR(response, error_msg, kUnknownError); + return; + } else if (code == kIncompatibleBrowserVersion) { + std::string error_msg = base::StringPrintf( + "Version of Chrome is incompatible with version of ChromeDriver. " + "Please update ChromeDriver and ensure you are using Chrome %d+.", + kMinSupportedChromeVersion); + SET_WEBDRIVER_ERROR(response, error_msg, kUnknownError); + return; + } else if (code != kSuccess) { + std::string error_msg = base::StringPrintf( + "Unknown error while initializing session. " + "Ensure ChromeDriver is up-to-date and Chrome is version %d+.", + kMinSupportedChromeVersion); + SET_WEBDRIVER_ERROR(response, error_msg, kUnknownError); return; } |