OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ |
6 #define CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ | 6 #define CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 namespace base { |
11 class Value; | 12 class Value; |
| 13 } |
12 | 14 |
13 namespace webdriver { | 15 namespace webdriver { |
14 | 16 |
15 // This class represents a WebDriver WebElement ID. These IDs are mapped to | 17 // This class represents a WebDriver WebElement ID. These IDs are mapped to |
16 // objects in a page in JavaScript. | 18 // objects in a page in JavaScript. |
17 class WebElementId { | 19 class WebElementId { |
18 public: | 20 public: |
19 // Creates an invalid WebElementId. | 21 // Creates an invalid WebElementId. |
20 WebElementId(); | 22 WebElementId(); |
21 | 23 |
22 // Creates a valid |WebElementId| using the ID of an element. An empty string | 24 // Creates a valid |WebElementId| using the ID of an element. An empty string |
23 // can be used to refer to the root document of the page. | 25 // can be used to refer to the root document of the page. |
24 explicit WebElementId(const std::string& id); | 26 explicit WebElementId(const std::string& id); |
25 | 27 |
26 // Creates a |WebElementId| from an element dictionary returned by a WebDriver | 28 // Creates a |WebElementId| from an element dictionary returned by a WebDriver |
27 // atom. It will be valid iff the dictionary is correctly constructed. | 29 // atom. It will be valid iff the dictionary is correctly constructed. |
28 explicit WebElementId(Value* value); | 30 explicit WebElementId(base::Value* value); |
29 | 31 |
30 ~WebElementId(); | 32 ~WebElementId(); |
31 | 33 |
32 // Returns the appropriate |Value| type to be used to identify the element | 34 // Returns the appropriate |Value| type to be used to identify the element |
33 // to a WebDriver atom. The client takes ownership. | 35 // to a WebDriver atom. The client takes ownership. |
34 Value* ToValue() const; | 36 base::Value* ToValue() const; |
35 | 37 |
36 // Returns whether this ID is valid. Even if the ID is valid, it may not refer | 38 // Returns whether this ID is valid. Even if the ID is valid, it may not refer |
37 // to a valid ID on the page. | 39 // to a valid ID on the page. |
38 bool is_valid() const; | 40 bool is_valid() const; |
39 | 41 |
40 private: | 42 private: |
41 std::string id_; | 43 std::string id_; |
42 bool is_valid_; | 44 bool is_valid_; |
43 }; | 45 }; |
44 | 46 |
45 // WebDriver element locators. These constants are used to identify different | 47 // WebDriver element locators. These constants are used to identify different |
46 // ways to locate an element to WebDriver atoms. Struct is used for grouping | 48 // ways to locate an element to WebDriver atoms. Struct is used for grouping |
47 // purposes. | 49 // purposes. |
48 struct LocatorType { | 50 struct LocatorType { |
49 static const char kClassName[]; | 51 static const char kClassName[]; |
50 static const char kCss[]; | 52 static const char kCss[]; |
51 static const char kId[]; | 53 static const char kId[]; |
52 static const char kLinkText[]; | 54 static const char kLinkText[]; |
53 static const char kName[]; | 55 static const char kName[]; |
54 static const char kPartialLinkText[]; | 56 static const char kPartialLinkText[]; |
55 static const char kTagName[]; | 57 static const char kTagName[]; |
56 static const char kXpath[]; | 58 static const char kXpath[]; |
57 }; | 59 }; |
58 | 60 |
59 } // namespace webdriver | 61 } // namespace webdriver |
60 | 62 |
61 #endif // CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ | 63 #endif // CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ |
OLD | NEW |