Appearance
Function: setProperty()
ts
function setProperty(
ctx: Context,
selector: string,
propertyName: string,
value: string,
options?: WaitForSelectorOptions): Promise<void>;Defined in: src/dom/index.ts:24
Change the value of an element property.
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | Context | Context object. |
selector | string | CSS or XPath selector for the target element. |
propertyName | string | The attribute name to set. |
value | string | The new attribute value. |
options? | WaitForSelectorOptions | Wait options for the selector lookup. |
Returns
Promise<void>
Example
ts
// Disable the "Buy Now" button while the cart loads
await setProperty(ctx, 'button#buy-now', 'disabled', 'true');