blob: b8a8ac33e92b35e30df5a63b179e43a851e03eaa (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright (c) 2011 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_WEBDRIVER_WEBDRIVER_ELEMENT_ID_H_
#define CHROME_TEST_WEBDRIVER_WEBDRIVER_ELEMENT_ID_H_
#pragma once
#include <string>
#include "chrome/test/automation/value_conversion_traits.h"
namespace base {
class Value;
}
namespace webdriver {
// This class represents a WebDriver Element ID. These IDs are mapped to
// objects in a page in JavaScript.
class ElementId {
public:
// Creates an invalid ElementId.
ElementId();
// Creates a valid |ElementId| using the ID of an element. An empty string
// can be used to refer to the root document of the page.
explicit ElementId(const std::string& id);
// Creates a |ElementId| from an element dictionary returned by a WebDriver
// atom. It will be valid iff the dictionary is correctly constructed.
explicit ElementId(const base::Value* value);
~ElementId();
// Returns the appropriate |Value| type to be used to identify the element
// to a WebDriver atom. The client takes ownership.
base::Value* ToValue() const;
// Returns whether this ID is valid. Even if the ID is valid, it may not refer
// to a valid ID on the page.
bool is_valid() const;
private:
std::string id_;
bool is_valid_;
};
// WebDriver element locators. These constants are used to identify different
// ways to locate an element to WebDriver atoms. Struct is used for grouping
// purposes.
struct LocatorType {
static const char kClassName[];
static const char kCss[];
static const char kId[];
static const char kLinkText[];
static const char kName[];
static const char kPartialLinkText[];
static const char kTagName[];
static const char kXpath[];
};
} // namespace webdriver
template <>
struct ValueConversionTraits<webdriver::ElementId> {
static base::Value* CreateValueFrom(const webdriver::ElementId& t);
static bool SetFromValue(
const base::Value* value, webdriver::ElementId* t);
static bool CanConvert(const base::Value* value);
};
#endif // CHROME_TEST_WEBDRIVER_WEBDRIVER_ELEMENT_ID_H_
|