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

Method AppendFrameDetails

cpp/iedriver/Element.cpp:1231–1411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1229}
1230
1231bool Element::AppendFrameDetails(std::vector<LocationInfo>* frame_locations) {
1232 LOG(TRACE) << "Entering Element::GetFrameDetails";
1233
1234 if (frame_locations == nullptr) {
1235 return false;
1236 }
1237
1238 CComPtr<IHTMLDocument2> owner_doc;
1239 int status_code = this->GetContainingDocument(true, &owner_doc);
1240 if (status_code != WD_SUCCESS) {
1241 LOG(WARN) << "Unable to get containing document";
1242 return false;
1243 }
1244
1245 CComPtr<IHTMLWindow2> owner_doc_window;
1246 HRESULT hr = owner_doc->get_parentWindow(&owner_doc_window);
1247 if (!owner_doc_window) {
1248 LOG(WARN) << "Unable to get parent window, call to IHTMLDocument2::get_parentWindow failed";
1249 return false;
1250 }
1251
1252 // Get the parent window to the current window, where "current window" is
1253 // the window containing the parent document of this element. If that parent
1254 // window exists, and it is not the same as the current window, we assume
1255 // this element exists inside a frame or iframe. If it is in a frame, get
1256 // the parent document containing the frame, so we can get the information
1257 // about the frame or iframe element hosting the document of this element.
1258 CComPtr<IHTMLWindow2> parent_window;
1259 hr = owner_doc_window->get_parent(&parent_window);
1260 if (parent_window && !owner_doc_window.IsEqualObject(parent_window)) {
1261 LOG(DEBUG) << "Element is in a frame.";
1262 CComPtr<IHTMLDocument2> parent_doc;
1263 status_code = this->GetDocumentFromWindow(parent_window, &parent_doc);
1264
1265 CComPtr<IHTMLFramesCollection2> frames;
1266 hr = parent_doc->get_frames(&frames);
1267
1268 long frame_count(0);
1269 hr = frames->get_length(&frame_count);
1270 CComVariant index;
1271 index.vt = VT_I4;
1272 for (long i = 0; i < frame_count; ++i) {
1273 // See if the document in each frame is this element's
1274 // owner document.
1275 index.lVal = i;
1276 CComVariant result;
1277 hr = frames->item(&index, &result);
1278 CComPtr<IHTMLWindow2> frame_window;
1279 result.pdispVal->QueryInterface<IHTMLWindow2>(&frame_window);
1280 if (!frame_window) {
1281 // Frame is not an HTML frame.
1282 continue;
1283 }
1284
1285 CComPtr<IHTMLDocument2> frame_doc;
1286 status_code = this->GetDocumentFromWindow(frame_window, &frame_doc);
1287
1288 if (frame_doc.IsEqualObject(owner_doc)) {

Callers 1

GetLocationMethod · 0.95

Calls 7

GetContainingDocumentMethod · 0.95
GetDocumentFromWindowMethod · 0.95
GetLocationMethod · 0.80
LOGClass · 0.50
AddArgumentMethod · 0.45
ExecuteMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected