2015-04-13 12:09:26 -04:00
|
|
|
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
|
// distributed with this work for additional information
|
|
|
|
|
// regarding copyright ownership. The SFC licenses this file
|
|
|
|
|
// to you under the Apache License, Version 2.0 (the "License");
|
2013-01-11 22:18:32 +01:00
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
|
|
#ifndef WEBDRIVER_IE_ELEMENT_H_
|
|
|
|
|
#define WEBDRIVER_IE_ELEMENT_H_
|
|
|
|
|
|
2013-02-25 11:32:30 -05:00
|
|
|
#include <memory>
|
2013-01-11 22:18:32 +01:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2017-02-14 09:48:56 -08:00
|
|
|
|
|
|
|
|
#include "ElementScrollBehavior.h"
|
2013-01-11 22:18:32 +01:00
|
|
|
#include "LocationInfo.h"
|
|
|
|
|
|
2018-02-07 12:04:43 -08:00
|
|
|
#define JSON_ELEMENT_PROPERTY_NAME "element-6066-11e4-a52e-4f735466cecf"
|
|
|
|
|
|
2017-02-14 09:48:56 -08:00
|
|
|
// Forward declaration of classes.
|
2014-08-19 21:11:00 +00:00
|
|
|
namespace Json {
|
|
|
|
|
class Value;
|
|
|
|
|
} // namespace Json
|
|
|
|
|
|
2013-01-11 22:18:32 +01:00
|
|
|
namespace webdriver {
|
|
|
|
|
|
2017-02-14 09:48:56 -08:00
|
|
|
// Forward declaration of classes.
|
2013-01-11 22:18:32 +01:00
|
|
|
class Browser;
|
|
|
|
|
|
|
|
|
|
class Element {
|
|
|
|
|
public:
|
|
|
|
|
Element(IHTMLElement* element, HWND containing_window_handle);
|
2018-02-07 12:04:43 -08:00
|
|
|
Element(IHTMLElement* element,
|
|
|
|
|
HWND containing_window_handle,
|
|
|
|
|
const std::string& element_id);
|
2013-01-11 22:18:32 +01:00
|
|
|
virtual ~Element(void);
|
|
|
|
|
Json::Value ConvertToJson(void);
|
|
|
|
|
std::string GetTagName(void);
|
2017-02-14 09:48:56 -08:00
|
|
|
int GetLocationOnceScrolledIntoView(const ElementScrollBehavior scroll,
|
2013-04-10 03:55:39 +04:00
|
|
|
LocationInfo* location,
|
|
|
|
|
std::vector<LocationInfo>* frame_locations);
|
2018-02-23 13:55:26 -08:00
|
|
|
int GetStaticClickLocation(LocationInfo* click_location);
|
2017-02-14 09:48:56 -08:00
|
|
|
int GetClickLocation(const ElementScrollBehavior scroll_behavior,
|
2013-05-09 16:20:57 -04:00
|
|
|
LocationInfo* element_location,
|
|
|
|
|
LocationInfo* click_location);
|
2013-01-11 22:18:32 +01:00
|
|
|
int GetAttributeValue(const std::string& attribute_name,
|
2018-02-22 07:07:33 -08:00
|
|
|
VARIANT* attribute_value);
|
2017-08-31 09:41:44 -07:00
|
|
|
int GetPropertyValue(const std::string& property_name,
|
2018-02-22 07:07:33 -08:00
|
|
|
VARIANT* property_value);
|
2013-07-08 13:43:53 -04:00
|
|
|
int GetCssPropertyValue(const std::string& property_name,
|
|
|
|
|
std::string* property_value);
|
2013-01-11 22:18:32 +01:00
|
|
|
|
2015-04-29 11:09:13 -04:00
|
|
|
int IsDisplayed(bool ignore_opacity, bool* result);
|
2013-01-11 22:18:32 +01:00
|
|
|
bool IsEnabled(void);
|
2018-08-31 07:32:49 -07:00
|
|
|
bool IsXmlDocument(IHTMLDocument2* doc);
|
2013-01-11 22:18:32 +01:00
|
|
|
bool IsSelected(void);
|
2013-05-02 09:17:28 -04:00
|
|
|
bool IsInteractable(void);
|
2013-05-02 11:08:07 -04:00
|
|
|
bool IsEditable(void);
|
2018-03-17 12:21:27 -07:00
|
|
|
bool IsFocusable(void);
|
2013-01-11 22:18:32 +01:00
|
|
|
bool IsAttachedToDom(void);
|
2018-02-05 12:52:43 -08:00
|
|
|
bool IsDocumentFocused(IHTMLDocument2* focused_doc);
|
2018-03-10 13:10:55 -08:00
|
|
|
bool IsObscured(LocationInfo* click_location,
|
2018-10-08 16:00:35 -07:00
|
|
|
long* obscuring_element_index,
|
2018-03-10 13:10:55 -08:00
|
|
|
std::string* obscuring_element_description);
|
2013-01-11 22:18:32 +01:00
|
|
|
|
2019-01-02 09:35:38 -08:00
|
|
|
|
2013-01-11 22:18:32 +01:00
|
|
|
std::string element_id(void) const { return this->element_id_; }
|
|
|
|
|
IHTMLElement* element(void) { return this->element_; }
|
|
|
|
|
|
|
|
|
|
private:
|
2013-08-20 16:58:46 -04:00
|
|
|
int GetLocation(LocationInfo* location,
|
|
|
|
|
std::vector<LocationInfo>* frame_locations);
|
|
|
|
|
LocationInfo CalculateClickPoint(const LocationInfo location,
|
|
|
|
|
const bool document_contains_frames);
|
|
|
|
|
bool GetClickableViewPortLocation(const bool document_contains_frames,
|
|
|
|
|
LocationInfo* location);
|
|
|
|
|
bool IsLocationInViewPort(const LocationInfo location,
|
|
|
|
|
const bool document_contains_frames);
|
|
|
|
|
bool IsLocationVisibleInFrames(const LocationInfo location,
|
|
|
|
|
const std::vector<LocationInfo> frame_locations);
|
2018-11-19 10:08:24 -08:00
|
|
|
bool IsHiddenByOverflow(const LocationInfo element_location,
|
|
|
|
|
const LocationInfo click_location);
|
2019-07-22 14:10:08 -07:00
|
|
|
bool IsEntirelyHiddenByOverflow(void);
|
|
|
|
|
bool ScrollWithinOverflow(const LocationInfo element_location);
|
2013-08-20 16:58:46 -04:00
|
|
|
bool AppendFrameDetails(std::vector<LocationInfo>* frame_locations);
|
2013-01-11 22:18:32 +01:00
|
|
|
int GetContainingDocument(const bool use_dom_node, IHTMLDocument2** doc);
|
|
|
|
|
int GetDocumentFromWindow(IHTMLWindow2* parent_window,
|
|
|
|
|
IHTMLDocument2** parent_doc);
|
2019-01-02 09:35:38 -08:00
|
|
|
|
|
|
|
|
std::string GetElementHtmlDescription(IHTMLElement* element);
|
|
|
|
|
bool HasShadowRoot(void);
|
|
|
|
|
|
2013-01-11 22:18:32 +01:00
|
|
|
bool IsInline(void);
|
2019-07-18 15:31:22 -07:00
|
|
|
bool IsImageMap(LocationInfo* location);
|
2013-11-07 12:27:41 -05:00
|
|
|
static bool RectHasNonZeroDimensions(IHTMLRect* rect);
|
2013-05-09 16:20:57 -04:00
|
|
|
|
2013-11-07 12:27:41 -05:00
|
|
|
bool HasFirstChildTextNodeOfMultipleChildren(void);
|
|
|
|
|
bool GetTextBoundaries(LocationInfo* text_info);
|
2013-01-11 22:18:32 +01:00
|
|
|
|
2018-10-03 14:11:06 -07:00
|
|
|
bool GetComputedStyle(IHTMLCSSStyleDeclaration** computed_style);
|
2018-09-18 11:59:39 -07:00
|
|
|
|
2013-01-11 22:18:32 +01:00
|
|
|
std::string element_id_;
|
|
|
|
|
CComPtr<IHTMLElement> element_;
|
|
|
|
|
HWND containing_window_handle_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webdriver
|
|
|
|
|
|
|
|
|
|
#endif // WEBDRIVER_IE_ELEMENT_H_
|