blob: 653aca4afee97662653ecf5662991c0576c989e1 [file] [log] [blame]
[email protected]2937a8c2011-05-20 15:02:331// Copyright (c) 2011 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_WEBDRIVER_WEBDRIVER_ERROR_H_
6#define CHROME_TEST_WEBDRIVER_WEBDRIVER_ERROR_H_
[email protected]2937a8c2011-05-20 15:02:337
8#include <string>
9
10#include "base/basictypes.h"
[email protected]2937a8c2011-05-20 15:02:3311
[email protected]b56da612011-12-16 23:10:5812namespace automation {
13class Error;
14}
15
[email protected]2937a8c2011-05-20 15:02:3316namespace webdriver {
17
18// Error codes defined by the WebDriver wire protcol.
19// If you add a code here, don't forget to add it to |ErrorCodeToString|.
20enum ErrorCode {
21 kSuccess = 0,
22 kNoSuchElement = 7,
23 kNoSuchFrame = 8,
24 kUnknownCommand = 9,
25 kStaleElementReference = 10,
26 kElementNotVisible = 11,
27 kInvalidElementState = 12,
28 kUnknownError = 13,
29 kElementNotSelectable = 15,
30 kXPathLookupError = 19,
31 kNoSuchWindow = 23,
32 kInvalidCookieDomain = 24,
33 kUnableToSetCookie = 25,
[email protected]b56da612011-12-16 23:10:5834 kUnexpectedAlertOpen = 26,
35 kNoAlertOpenError = 27,
[email protected]2937a8c2011-05-20 15:02:3336
37 // HTTP status codes.
38 kSeeOther = 303,
39 kBadRequest = 400,
40 kSessionNotFound = 404,
41 kMethodNotAllowed = 405,
42 kInternalServerError = 500,
43};
44
45// Represents a WebDriver error and the context within which the error occurred.
46class Error {
47 public:
[email protected]b56da612011-12-16 23:10:5848 static Error* FromAutomationError(const automation::Error& error);
49
[email protected]2937a8c2011-05-20 15:02:3350 explicit Error(ErrorCode code);
51
52 Error(ErrorCode code, const std::string& details);
53
54 virtual ~Error();
55
56 void AddDetails(const std::string& details);
57
[email protected]2937a8c2011-05-20 15:02:3358 ErrorCode code() const;
59 const std::string& details() const;
[email protected]2937a8c2011-05-20 15:02:3360
61 private:
62 ErrorCode code_;
63 std::string details_;
[email protected]2937a8c2011-05-20 15:02:3364
65 DISALLOW_COPY_AND_ASSIGN(Error);
66};
67
68} // namespace webdriver
69
70#endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_ERROR_H_