Skip to main content
Locator content methods for the Playwright driver.

innerHTML

Returns the innerHTML of the element. Upstream docs
options
{ timeout?: number }
result
string
Return value
await locator.innerHTML();

innerText

Returns the innerText of the element.
For assertions, prefer expect(locator).toHaveText() with useInnerText option.
Upstream docs
options
{ timeout?: number }
result
string
Return value
await locator.innerText();

textContent

Returns the textContent of the element.
For assertions, prefer expect(locator).toHaveText().
Upstream docs
options
{ timeout?: number }
result
string | null
Return value
await locator.textContent();

allInnerTexts

Returns an array of innerText values for all matching elements.
For assertions, prefer expect(locator).toHaveText() with useInnerText option.
Upstream docs
result
string[]
Return value
await locator.allInnerTexts();

allTextContents

Returns an array of textContent values for all matching elements.
For assertions, prefer expect(locator).toHaveText().
Upstream docs
result
string[]
Return value
await locator.allTextContents();

getAttribute

Returns the attribute value of the element. Upstream docs
name
string
required
Attribute name
options
{ timeout?: number }
result
string | null
Return value
await locator.getAttribute('...');

inputValue

Returns the input value for <input>, <textarea>, or <select> elements. Upstream docs
options
{ timeout?: number }
result
string
Return value
await locator.inputValue();