Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
seleniumhq
GitHub Repository: seleniumhq/selenium
Path: blob/trunk/cpp/iedriver/Element.h
2867 views
1
// Licensed to the Software Freedom Conservancy (SFC) under one
2
// or more contributor license agreements. See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership. The SFC licenses this file
5
// to you under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#ifndef WEBDRIVER_IE_ELEMENT_H_
18
#define WEBDRIVER_IE_ELEMENT_H_
19
20
#include <memory>
21
#include <string>
22
#include <vector>
23
24
#include "ElementScrollBehavior.h"
25
#include "LocationInfo.h"
26
27
#define JSON_ELEMENT_PROPERTY_NAME "element-6066-11e4-a52e-4f735466cecf"
28
29
// Forward declaration of classes.
30
namespace Json {
31
class Value;
32
} // namespace Json
33
34
namespace webdriver {
35
36
// Forward declaration of classes.
37
class Browser;
38
39
class Element {
40
public:
41
Element(IHTMLElement* element, HWND containing_window_handle);
42
Element(IHTMLElement* element,
43
HWND containing_window_handle,
44
const std::string& element_id);
45
virtual ~Element(void);
46
Json::Value ConvertToJson(void);
47
std::string GetTagName(void);
48
int GetLocationOnceScrolledIntoView(const ElementScrollBehavior scroll,
49
LocationInfo* location,
50
std::vector<LocationInfo>* frame_locations);
51
int GetStaticClickLocation(LocationInfo* click_location);
52
int GetClickLocation(const ElementScrollBehavior scroll_behavior,
53
LocationInfo* element_location,
54
LocationInfo* click_location);
55
int GetAttributeValue(const std::string& attribute_name,
56
VARIANT* attribute_value);
57
int GetPropertyValue(const std::string& property_name,
58
VARIANT* property_value);
59
int GetCssPropertyValue(const std::string& property_name,
60
std::string* property_value);
61
62
int IsDisplayed(bool ignore_opacity, bool* result);
63
bool IsEnabled(void);
64
bool IsXmlDocument(IHTMLDocument2* doc);
65
bool IsSelected(void);
66
bool IsInteractable(void);
67
bool IsEditable(void);
68
bool IsFocusable(void);
69
bool IsAttachedToDom(void);
70
bool IsDocumentFocused(IHTMLDocument2* focused_doc);
71
bool IsObscured(LocationInfo* click_location,
72
long* obscuring_element_index,
73
std::string* obscuring_element_description);
74
75
76
std::string element_id(void) const { return this->element_id_; }
77
IHTMLElement* element(void) { return this->element_; }
78
79
private:
80
int GetLocation(LocationInfo* location,
81
std::vector<LocationInfo>* frame_locations);
82
LocationInfo CalculateClickPoint(const LocationInfo location,
83
const bool document_contains_frames);
84
bool GetClickableViewPortLocation(const bool document_contains_frames,
85
LocationInfo* location);
86
bool IsLocationInViewPort(const LocationInfo location,
87
const bool document_contains_frames);
88
bool IsLocationVisibleInFrames(const LocationInfo location,
89
const std::vector<LocationInfo> frame_locations);
90
bool IsHiddenByOverflow(const LocationInfo element_location,
91
const LocationInfo click_location);
92
bool IsEntirelyHiddenByOverflow(void);
93
bool ScrollWithinOverflow(const LocationInfo element_location);
94
bool AppendFrameDetails(std::vector<LocationInfo>* frame_locations);
95
int GetContainingDocument(const bool use_dom_node, IHTMLDocument2** doc);
96
int GetDocumentFromWindow(IHTMLWindow2* parent_window,
97
IHTMLDocument2** parent_doc);
98
99
std::string GetElementHtmlDescription(IHTMLElement* element);
100
bool HasShadowRoot(void);
101
102
bool IsInline(void);
103
bool IsImageMap(LocationInfo* location);
104
static bool RectHasNonZeroDimensions(IHTMLRect* rect);
105
106
bool HasFirstChildTextNodeOfMultipleChildren(void);
107
bool GetTextBoundaries(LocationInfo* text_info);
108
109
bool GetComputedStyle(IHTMLCSSStyleDeclaration** computed_style);
110
111
std::string element_id_;
112
CComPtr<IHTMLElement> element_;
113
HWND containing_window_handle_;
114
};
115
116
} // namespace webdriver
117
118
#endif // WEBDRIVER_IE_ELEMENT_H_
119
120