Skip to content

Get Attribute

Type: page-get-attribute  ·  Package: Browser v1.0.9  ·  Output: string

Reads the value of an HTML attribute of an element. It’s for extracting data that isn’t visible text: a button’s download link (href), an image URL (src), a hidden identifier (data-id), or an element’s state (class, disabled).

It locates the element by its selector, waits for it to exist on the page (it doesn’t need to be visible) and returns the value of the attribute named in attribute.

  • It reads the attribute as written in the HTML: a relative href (/invoices/12.pdf) is returned relative. Download File already knows how to complete it.
  • It reads the attribute, not the element’s live property: for the current value of a field use Get Value.
ParameterTypeDefaultDescription
selectorselector—The element to read the attribute from.
attributestring—Name of the HTML attribute. E.g. href, src, data-id, class.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page).
timeoutnumber30000Maximum time in ms to wait for the element. Empty, 0 or negative: the project settings value or, if none, 30000.

Returns a string with the attribute’s value. If the element doesn’t have that attribute, the output is empty (null); an attribute without a value, like disabled, returns "".

Get the download link of a document and download it:

Page Get Attribute selector = (#enlaceFactura) attribute = "href" → output: urlPdf
Download File url = urlPdf outputPath = "C:\Invoices" → output: rutaPdf

Find out whether a button is disabled:

Page Get Attribute selector = (#btnEnviar) attribute = "disabled" → output: deshabilitado
If condition = deshabilitado != null
└─ then:
Log message = "Submission is not available yet"
MessageCause and fix
'attribute' is required.You didn’t set the attribute name.
Timeout 30000ms exceededThe element didn’t appear in time. Check the selector or wait first with Wait For.
strict mode violation: … resolved to 2 elementsThe selector matches several elements. Make it more specific or add an index.
'page' must be a ZoanPageSession.page is empty outside a body.
  • Get Text — read the visible text instead of an attribute.
  • Get Value — read the value of a form field.
  • Download File — download the file behind an href.