summaryrefslogtreecommitdiffstats
path: root/chrome/test/chromedriver/status.h
blob: 3ba7ee5a732cd4746c1efd78d386317ee6816805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_TEST_CHROMEDRIVER_STATUS_H_
#define CHROME_TEST_CHROMEDRIVER_STATUS_H_

#include <string>

// WebDriver standard status codes.
enum StatusCode {
  kOk = 0,
  kNoSuchElement = 7,
  kUnknownCommand = 9,
  kStaleElementReference = 10,
  kElementNotVisible = 11,
  kInvalidElementState = 12,
  kUnknownError = 13,
  kJavaScriptError = 17,
  kXPathLookupError = 19,
  kNoSuchWindow = 23,
  kInvalidCookieDomain = 24,
  kUnexpectedAlertOpen = 26,
  kNoAlertOpen = 27,
  kScriptTimeout = 28,
  kInvalidSelector = 32,
  kSessionNotCreatedException = 33,
  // Chrome-specific status codes.
  kNoSuchSession = 100,
  kNoSuchFrame,
  kChromeNotReachable,
  kDisconnected,
};

// Represents a WebDriver status, which may be an error or ok.
class Status {
 public:
  explicit Status(StatusCode code);
  Status(StatusCode code, const std::string& details);
  Status(StatusCode code, const Status& cause);
  Status(StatusCode code, const std::string& details, const Status& cause);
  ~Status();

  void AddDetails(const std::string& details);

  bool IsOk() const;
  bool IsError() const;

  StatusCode code() const;

  const std::string& message() const;

 private:
  StatusCode code_;
  std::string msg_;
};

#endif  // CHROME_TEST_CHROMEDRIVER_STATUS_H_