Home | History | Annotate | Download | only in chrome
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_TEST_CHROMEDRIVER_CHROME_STATUS_H_
      6 #define CHROME_TEST_CHROMEDRIVER_CHROME_STATUS_H_
      7 
      8 #include <string>
      9 
     10 // WebDriver standard status codes.
     11 enum StatusCode {
     12   kOk = 0,
     13   kNoSuchSession = 6,
     14   kNoSuchElement = 7,
     15   kNoSuchFrame = 8,
     16   kUnknownCommand = 9,
     17   kStaleElementReference = 10,
     18   kElementNotVisible = 11,
     19   kInvalidElementState = 12,
     20   kUnknownError = 13,
     21   kJavaScriptError = 17,
     22   kXPathLookupError = 19,
     23   kTimeout = 21,
     24   kNoSuchWindow = 23,
     25   kInvalidCookieDomain = 24,
     26   kUnexpectedAlertOpen = 26,
     27   kNoAlertOpen = 27,
     28   kScriptTimeout = 28,
     29   kInvalidSelector = 32,
     30   kSessionNotCreatedException = 33,
     31   // Chrome-specific status codes.
     32   kChromeNotReachable = 100,
     33   kNoSuchExecutionContext,
     34   kDisconnected,
     35   kForbidden = 103,
     36   kTabCrashed,
     37 };
     38 
     39 // Represents a WebDriver status, which may be an error or ok.
     40 class Status {
     41  public:
     42   explicit Status(StatusCode code);
     43   Status(StatusCode code, const std::string& details);
     44   Status(StatusCode code, const Status& cause);
     45   Status(StatusCode code, const std::string& details, const Status& cause);
     46   ~Status();
     47 
     48   void AddDetails(const std::string& details);
     49 
     50   bool IsOk() const;
     51   bool IsError() const;
     52 
     53   StatusCode code() const;
     54 
     55   const std::string& message() const;
     56 
     57  private:
     58   StatusCode code_;
     59   std::string msg_;
     60 };
     61 
     62 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_STATUS_H_
     63