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

Method IsEnabled

cpp/iedriver/Element.cpp:138–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138bool Element::IsEnabled() {
139 LOG(TRACE) << "Entering Element::IsEnabled";
140
141 bool result = false;
142
143 // The atom is just the definition of an anonymous
144 // function: "function() {...}"; Wrap it in another function so we can
145 // invoke it with our arguments without polluting the current namespace.
146 std::wstring script_source(L"(function() { return (");
147 script_source += atoms::asString(atoms::IS_ENABLED);
148 script_source += L")})();";
149
150 CComPtr<IHTMLDocument2> doc;
151 this->GetContainingDocument(false, &doc);
152
153 if (this->IsXmlDocument(doc)) {
154 return false;
155 }
156
157 Script script_wrapper(doc, script_source, 1);
158 script_wrapper.AddArgument(this->element_);
159 int status_code = script_wrapper.Execute();
160
161 if (status_code == WD_SUCCESS) {
162 result = script_wrapper.result().boolVal == VARIANT_TRUE;
163 } else {
164 LOG(WARN) << "Failed to determine is element enabled";
165 }
166
167 return result;
168}
169
170bool Element::IsXmlDocument(IHTMLDocument2* doc) {
171 LOG(TRACE) << "Entering Element::IsXmlDocument";

Callers 3

ExecuteInternalMethod · 0.45
IsElementInteractableMethod · 0.45
ExecuteInternalMethod · 0.45

Calls 7

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

Tested by

no test coverage detected