Element Info & Attributes

Get Attribute

Retrieves the value of a specified attribute or property from the element and returns it as the response.

NOTE

For bulk extraction across every matched element, use selector.UseAttribute(attribute) together with GetGrid (the attribute value becomes a grid column). To write an attribute instead of reading it, see SetAttribute.

Examples

GPAL Fluent: High-level fluent C# API

var attribuite = gPalElement.GetAttribute("data-username");

MagicHelper: MagicHelper utility library

GPAL.MagicHelper.GetAttribute(string css);

GPAL.MagicHelper.GetAttribute(string xpath);

Puppeteer Client: Puppeteer-style C# client

browser.PuppeteerClient.GetAttribute(string css).WithAttribute(string attribute).Execute();

browser.PuppeteerClient.GetAttribute(string xpath).WithAttribute(string attribute).Execute();

Puppeteer Communicator: Low-level communicator

//PuppeteerCommunicator's GetAttribute takes a resolved backendNodeId, not a raw CSS/XPath selector.

await browser.PuppeteerCommunicator.GetAttribute(int backendNodeId, string attribute, string sessionId);

REST Client: Direct REST/HTTP client

GPAL.OttoMagicClient.WithEndpoint(ApiEndpoint.GetAttribute).WithCss(string css).WithAttribute(string attribute).Execute();

GPAL.OttoMagicClient.WithEndpoint(ApiEndpoint.GetAttribute).WithXPath(string xpath).WithAttribute(string attribute).Execute();

💬 Ask GPAL