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

Method GetArrayItem

cpp/iedriver/VariantUtilities.cpp:484–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482}
483
484int VariantUtilities::GetArrayItem(IDispatch* array_dispatch,
485 long index,
486 VARIANT* item){
487 LOG(TRACE) << "Entering Script::GetArrayItem";
488 std::wstring index_string = std::to_wstring(static_cast<long long>(index));
489 CComVariant array_item_variant;
490 bool get_array_item_success = GetVariantObjectPropertyValue(array_dispatch,
491 index_string,
492 item);
493
494 if (!get_array_item_success) {
495 // Array-like item doesn't have indexed items; try using the
496 // 'item' method to access the elements in the collection.
497 LPOLESTR item_method_pointer = L"item";
498 DISPID dispid_item;
499 HRESULT hr = array_dispatch->GetIDsOfNames(IID_NULL,
500 &item_method_pointer,
501 1,
502 LOCALE_USER_DEFAULT,
503 &dispid_item);
504 if (FAILED(hr)) {
505 return EUNEXPECTEDJSERROR;
506 }
507
508 std::vector<CComVariant> argument_array_copy(2);
509 argument_array_copy[0] = index;
510 argument_array_copy[1] = array_dispatch;
511 DISPPARAMS call_parameters = { 0 };
512 memset(&call_parameters, 0, sizeof call_parameters);
513 call_parameters.cArgs = 2;
514 call_parameters.rgvarg = &argument_array_copy[0];
515 hr = array_dispatch->Invoke(dispid_item,
516 IID_NULL,
517 LOCALE_USER_DEFAULT,
518 DISPATCH_METHOD,
519 &call_parameters,
520 item,
521 NULL,
522 NULL);
523 if (FAILED(hr)) {
524 return EUNEXPECTEDJSERROR;
525 }
526 }
527 return WD_SUCCESS;
528}
529
530int VariantUtilities::GetAllVariantObjectPropertyValues(IElementManager* element_manager,
531 VARIANT variant_value,

Callers

nothing calls this directly

Calls 2

InvokeMethod · 0.80
LOGClass · 0.50

Tested by

no test coverage detected