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

Method GetAttributeValue

cpp/iedriver/Element.cpp:572–600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572int Element::GetAttributeValue(const std::string& attribute_name,
573 VARIANT* attribute_value) {
574 LOG(TRACE) << "Entering Element::GetAttributeValue";
575
576 std::wstring wide_attribute_name = StringUtilities::ToWString(attribute_name);
577 int status_code = WD_SUCCESS;
578
579 // The atom is just the definition of an anonymous
580 // function: "function() {...}"; Wrap it in another function so we can
581 // invoke it with our arguments without polluting the current namespace.
582 std::wstring script_source(L"(function() { return (");
583 script_source += atoms::asString(atoms::GET_ATTRIBUTE);
584 script_source += L")})();";
585
586 CComPtr<IHTMLDocument2> doc;
587 this->GetContainingDocument(false, &doc);
588 Script script_wrapper(doc, script_source, 2);
589 script_wrapper.AddArgument(this->element_);
590 script_wrapper.AddArgument(wide_attribute_name);
591 status_code = script_wrapper.Execute();
592
593 if (status_code == WD_SUCCESS) {
594 ::VariantCopy(attribute_value, &script_wrapper.result());
595 } else {
596 LOG(WARN) << "Failed to determine element attribute";
597 }
598
599 return WD_SUCCESS;
600}
601
602int Element::GetPropertyValue(const std::string& property_name,
603 VARIANT* property_value) {

Callers 3

IsPossibleNavigationMethod · 0.80
ExecuteInternalMethod · 0.80
HasMultipleAttributeMethod · 0.80

Calls 6

GetContainingDocumentMethod · 0.95
asStringFunction · 0.85
LOGClass · 0.50
AddArgumentMethod · 0.45
ExecuteMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected