Navigation

Set Attribute

Set element attribute value.

Set element attribute value.

Sets the value of a given attribute on an element, replacing any existing value for that attribute or adding it if missing.

TIP

This is a low-level DOM write, distinct from SendString and FillInAppend/FillInInsert/FillInOverwrite. It does not simulate typing, does not honor GPAL.WithTypingDelay, and does not fire input/change events on its own - follow up with FireChangeEvent if the page needs to react to the new value. Hardware automation has no equivalent operation, so it falls back to whichever of Selenium/JavaScript or Puppeteer is configured.

Examples

GPAL Fluent: High-level fluent C# API

//WithAttribute names the DOM attribute; the chained SetAttribute(value) call assigns the value via element.setAttribute(attribute, value) and completes the action. GPALElement.SetAttribute is the equivalent helper on an already-resolved element (mirrors GPALElement.GetAttribute), useful inside CallIf handlers or workflow code.

browser.WithSelector(selector) .WithAttribute("disabled") .SetAttribute("true"); gPalElement.SetAttribute("disabled", "true");

MagicHelper: MagicHelper utility library

GPAL.MagicHelper.SetAttribute(string css, string attribute, string value); GPAL.MagicHelper.SetAttribute(string xpath, string attribute, string value);

Puppeteer Client: Puppeteer-style C# client

browser.PuppeteerClient.SetAttribute(string css).WithAttribute(string attribute).WithValue(string value).Execute(); browser.PuppeteerClient.SetAttribute(string xpath).WithAttribute(string attribute).WithValue(string value).Execute();

Puppeteer Communicator: Low-level communicator

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

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

REST Client: Direct REST/HTTP client

GPAL.OttoMagicClient.WithEndpoint(ApiEndpoint.SetAttribute).WithCss(string css).WithAttribute(string attribute).WithValue(string value).Execute(); GPAL.OttoMagicClient.WithEndpoint(ApiEndpoint.SetAttribute).WithXPath(string xpath).WithAttribute(string attribute).WithValue(string value).Execute();