Playwright · Method
locator.getAttribute
Reads an attribute from the element matched by a locator. It returns the attribute value or null when the attribute is missing.
Last updated
- Since
- v1.14
Syntax
locator.getAttribute(name)
locator.getAttribute(name, options)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
Locatorexpect(locator).toHaveAttribute()getByRolepage.locator()