MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / GetElement

Method GetElement

cpp/iedriver/IECommandHandler.cpp:42–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42int IECommandHandler::GetElement(const IECommandExecutor& executor,
43 const std::string& element_id,
44 ElementHandle* element_wrapper) {
45 LOG(TRACE) << "Entering IECommandHandler::GetElement";
46 ElementHandle candidate_wrapper;
47 int result = executor.GetManagedElement(element_id, &candidate_wrapper);
48 if (result != WD_SUCCESS) {
49 LOG(WARN) << "Unable to get managed element, element not found";
50 return result;
51 } else {
52 if (!candidate_wrapper->IsAttachedToDom()) {
53 LOG(WARN) << "Found managed element is no longer valid";
54 IECommandExecutor& mutable_executor = const_cast<IECommandExecutor&>(executor);
55 mutable_executor.RemoveManagedElement(element_id);
56 return EOBSOLETEELEMENT;
57 } else {
58 // If the element is attached to the DOM, validate that its document
59 // is the currently-focused document (via frames).
60 BrowserHandle current_browser;
61 executor.GetCurrentBrowser(&current_browser);
62 CComPtr<IHTMLDocument2> focused_doc;
63 current_browser->GetDocument(&focused_doc);
64
65 if (candidate_wrapper->IsDocumentFocused(focused_doc)) {
66 *element_wrapper = candidate_wrapper;
67 return WD_SUCCESS;
68 } else {
69 LOG(WARN) << "Found managed element's document is not currently focused";
70 }
71 }
72 }
73
74 return EOBSOLETEELEMENT;
75}
76
77Json::Value IECommandHandler::RecreateJsonParameterObject(const ParametersMap& command_parameters) {
78 Json::Value result;

Callers 15

ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80
ExecuteInternalMethod · 0.80

Calls 7

IsAttachedToDomMethod · 0.80
GetCurrentBrowserMethod · 0.80
IsDocumentFocusedMethod · 0.80
LOGClass · 0.50
GetManagedElementMethod · 0.45
RemoveManagedElementMethod · 0.45
GetDocumentMethod · 0.45

Tested by

no test coverage detected