#include "chrome/test/chromedriver/element_util.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/containers/adapters.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/test/chromedriver/basic_types.h"
#include "chrome/test/chromedriver/chrome/browser_info.h"
#include "chrome/test/chromedriver/chrome/chrome.h"
#include "chrome/test/chromedriver/chrome/js.h"
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/web_view.h"
#include "chrome/test/chromedriver/net/timeout.h"
#include "chrome/test/chromedriver/session.h"
#include "third_party/selenium-atoms/atoms.h"
namespace {
const char kElementKey[] = …;
const char kElementKeyW3C[] = …;
const char kShadowRootKey[] = …;
const char kFindSubFrameScript[] = …;
bool ParseFromValue(base::Value* value, WebPoint* point) { … }
bool ParseFromValue(base::Value* value, WebSize* size) { … }
bool ParseFromValue(base::Value* value, WebRect* rect) { … }
base::Value::Dict CreateValueFrom(const WebRect& rect) { … }
Status CallAtomsJs(const std::string& frame,
WebView* web_view,
const char* const* atom_function,
const base::Value::List& args,
std::unique_ptr<base::Value>* result) { … }
Status VerifyElementClickable(const std::string& frame,
WebView* web_view,
const std::string& element_id,
const WebPoint& location) { … }
Status ScrollElementRegionIntoViewHelper(
const std::string& frame,
WebView* web_view,
const std::string& element_id,
const WebRect& region,
bool center,
const std::string& clickable_element_id,
WebPoint* location) { … }
Status GetElementEffectiveStyle(const std::string& frame,
WebView* web_view,
const std::string& element_id,
const std::string& property,
std::string* value) { … }
Status GetElementBorder(
const std::string& frame,
WebView* web_view,
const std::string& element_id,
int* border_left,
int* border_top) { … }
Status GetElementLocationInViewCenterHelper(const std::string& frame,
WebView* web_view,
const std::string& element_id,
bool center,
WebPoint* location) { … }
}
std::string GetElementKey() { … }
base::Value CreateElementCommon(const std::string& key,
const std::string& value) { … }
base::Value CreateElement(const std::string& element_id) { … }
base::Value CreateShadowRoot(const std::string& shadow_root_id) { … }
base::Value::Dict CreateValueFrom(const WebPoint& point) { … }
Status FindElementCommon(int interval_ms,
bool only_one,
const std::string* root_element_id,
Session* session,
WebView* web_view,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value,
bool is_shadow_root) { … }
Status FindElement(int interval_ms,
bool only_one,
const std::string* root_element_id,
Session* session,
WebView* web_view,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status FindShadowElement(int interval_ms,
bool only_one,
const std::string* shadow_root_id,
Session* session,
WebView* web_view,
const base::Value::Dict& params,
std::unique_ptr<base::Value>* value) { … }
Status GetActiveElement(Session* session,
WebView* web_view,
std::unique_ptr<base::Value>* value) { … }
Status HasFocus(Session* session, WebView* web_view, bool* has_focus) { … }
Status IsElementFocused(
Session* session,
WebView* web_view,
const std::string& element_id,
bool* is_focused) { … }
Status IsDocumentTypeXml(
Session* session,
WebView* web_view,
bool* is_xml_document) { … }
Status GetElementAttribute(Session* session,
WebView* web_view,
const std::string& element_id,
const std::string& attribute_name,
std::unique_ptr<base::Value>* value) { … }
Status IsElementAttributeEqualToIgnoreCase(
Session* session,
WebView* web_view,
const std::string& element_id,
const std::string& attribute_name,
const std::string& attribute_value,
bool* is_equal) { … }
Status GetElementClickableLocation(
Session* session,
WebView* web_view,
const std::string& element_id,
WebPoint* location) { … }
Status GetElementEffectiveStyle(
Session* session,
WebView* web_view,
const std::string& element_id,
const std::string& property_name,
std::string* property_value) { … }
Status GetElementRegion(Session* session,
WebView* web_view,
const std::string& element_id,
WebRect* rect) { … }
Status GetElementTagName(Session* session,
WebView* web_view,
const std::string& element_id,
std::string* name) { … }
Status GetElementSize(Session* session,
WebView* web_view,
const std::string& element_id,
WebSize* size) { … }
Status IsElementDisplayed(Session* session,
WebView* web_view,
const std::string& element_id,
bool ignore_opacity,
bool* is_displayed) { … }
Status IsElementEnabled(Session* session,
WebView* web_view,
const std::string& element_id,
bool* is_enabled) { … }
Status IsOptionElementSelected(Session* session,
WebView* web_view,
const std::string& element_id,
bool* is_selected) { … }
Status IsOptionElementTogglable(Session* session,
WebView* web_view,
const std::string& element_id,
bool* is_togglable) { … }
Status SetOptionElementSelected(Session* session,
WebView* web_view,
const std::string& element_id,
bool selected) { … }
Status ToggleOptionElement(
Session* session,
WebView* web_view,
const std::string& element_id) { … }
Status ScrollElementIntoView(
Session* session,
WebView* web_view,
const std::string& id,
const WebPoint* offset,
WebPoint* location) { … }
Status ScrollElementRegionIntoView(
Session* session,
WebView* web_view,
const std::string& element_id,
const WebRect& region,
bool center,
const std::string& clickable_element_id,
WebPoint* location) { … }
Status GetElementLocationInViewCenter(Session* session,
WebView* web_view,
const std::string& element_id,
WebPoint* location) { … }
Status GetAXNodeByElementId(Session* session,
WebView* web_view,
const std::string& element_id,
std::unique_ptr<base::Value>* axNode) { … }