Gets the value of the specified attribute or property for this element. The name of the attribute or property. The attribute's or property's current value. Returns a if the value is not set. The method will return the current value of the attribute or property, eve
(string attributeName)
| 431 | /// </remarks> |
| 432 | /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception> |
| 433 | public virtual string? GetAttribute(string attributeName) |
| 434 | { |
| 435 | Dictionary<string, object> parameters = new Dictionary<string, object>(); |
| 436 | string atom = GetWrappedAtom("get_attribute", ResourceUtilities.GetAttributeAtom); |
| 437 | parameters.Add("script", atom); |
| 438 | parameters.Add("args", new object[] { ((IWebDriverObjectReference)this).ToDictionary(), attributeName }); |
| 439 | |
| 440 | Response commandResponse = Execute(DriverCommand.ExecuteScript, parameters); |
| 441 | |
| 442 | |
| 443 | // Normalize string values of boolean results as lowercase. |
| 444 | if (commandResponse.Value is bool b) |
| 445 | { |
| 446 | return b ? "true" : "false"; |
| 447 | } |
| 448 | |
| 449 | return commandResponse.Value?.ToString(); |
| 450 | } |
| 451 | |
| 452 | /// <summary> |
| 453 | /// Gets the value of a declared HTML attribute of this element. |
no test coverage detected