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 };
     36 
     37 // Represents a WebDriver status, which may be an error or ok.
     38 class Status {
     39  public:
     40   explicit Status(StatusCode code);
     41   Status(StatusCode code, const std::string& details);
     42   Status(StatusCode code, const Status& cause);
     43   Status(StatusCode code, const std::string& details, const Status& cause);
     44   ~Status();
     45 
     46   void AddDetails(const std::string& details);
     47 
     48   bool IsOk() const;
     49   bool IsError() const;
     50 
     51   StatusCode code() const;
     52 
     53   const std::string& message() const;
     54 
     55  private:
     56   StatusCode code_;
     57   std::string msg_;
     58 };
     59 
     60 #endif  // CHROME_TEST_CHROMEDRIVER_CHROME_STATUS_H_
     61