Skip to content

I.getText() ​

Gets the visible text content of an element.

This returns the text as seen by the user, with HTML markup removed.

Usage ​

js
var text = I.getText(element: string)

Parameters ​

ParameterTypeDescription
elementstringTarget element — by CSS or XPath selector

Returns ​

Returns the visible text content of the element as a string.

Example ​

js
I.click("Show passphrase")
var passphrase = I.getText(".passphrase")
TEST.log.info("Passphrase: ", passphrase)

In this example, the test retrieves the visible text from the .passphrase element using I.getText() and logs the value to the test report.