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 #include "chrome/test/automation/value_conversion_traits.h" | |
12 | |
11 namespace base { | 13 namespace base { |
12 class Value; | 14 class Value; |
13 } | 15 } |
14 | 16 |
15 namespace webdriver { | 17 namespace webdriver { |
16 | 18 |
17 // This class represents a WebDriver WebElement ID. These IDs are mapped to | 19 // This class represents a WebDriver WebElement ID. These IDs are mapped to |
18 // objects in a page in JavaScript. | 20 // objects in a page in JavaScript. |
19 class WebElementId { | 21 class WebElementId { |
20 public: | 22 public: |
21 // Creates an invalid WebElementId. | 23 // Creates an invalid WebElementId. |
22 WebElementId(); | 24 WebElementId(); |
23 | 25 |
24 // Creates a valid |WebElementId| using the ID of an element. An empty string | 26 // Creates a valid |WebElementId| using the ID of an element. An empty string |
25 // can be used to refer to the root document of the page. | 27 // can be used to refer to the root document of the page. |
26 explicit WebElementId(const std::string& id); | 28 explicit WebElementId(const std::string& id); |
27 | 29 |
28 // Creates a |WebElementId| from an element dictionary returned by a WebDriver | 30 // Creates a |WebElementId| from an element dictionary returned by a WebDriver |
29 // atom. It will be valid iff the dictionary is correctly constructed. | 31 // atom. It will be valid iff the dictionary is correctly constructed. |
30 explicit WebElementId(base::Value* value); | 32 explicit WebElementId(const base::Value* value); |
31 | 33 |
32 ~WebElementId(); | 34 ~WebElementId(); |
33 | 35 |
34 // Returns the appropriate |Value| type to be used to identify the element | 36 // Returns the appropriate |Value| type to be used to identify the element |
35 // to a WebDriver atom. The client takes ownership. | 37 // to a WebDriver atom. The client takes ownership. |
36 base::Value* ToValue() const; | 38 base::Value* ToValue() const; |
37 | 39 |
38 // Returns whether this ID is valid. Even if the ID is valid, it may not refer | 40 // Returns whether this ID is valid. Even if the ID is valid, it may not refer |
39 // to a valid ID on the page. | 41 // to a valid ID on the page. |
40 bool is_valid() const; | 42 bool is_valid() const; |
(...skipping 12 matching lines...) Expand all Loading... | |
53 static const char kId[]; | 55 static const char kId[]; |
54 static const char kLinkText[]; | 56 static const char kLinkText[]; |
55 static const char kName[]; | 57 static const char kName[]; |
56 static const char kPartialLinkText[]; | 58 static const char kPartialLinkText[]; |
57 static const char kTagName[]; | 59 static const char kTagName[]; |
58 static const char kXpath[]; | 60 static const char kXpath[]; |
59 }; | 61 }; |
60 | 62 |
61 } // namespace webdriver | 63 } // namespace webdriver |
62 | 64 |
65 template <> | |
66 struct ValueConversionTraits<webdriver::WebElementId> { | |
Paweł Hajdan Jr.
2011/08/02 20:04:47
Why here? I think you may risk different behavior
kkania
2011/08/03 17:07:56
I was not quite sure where to put it myself. I tho
Paweł Hajdan Jr.
2011/08/04 17:51:36
After thinking more about it I still think it'd be
| |
67 static base::Value* CreateValueFrom(const webdriver::WebElementId& t); | |
68 static bool SetFromValue( | |
69 const base::Value* value, webdriver::WebElementId* t); | |
70 static bool CanConvert(const base::Value* value); | |
71 }; | |
72 | |
63 #endif // CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ | 73 #endif // CHROME_TEST_WEBDRIVER_WEB_ELEMENT_ID_H_ |
OLD | NEW |