Get the value of an input element


Parameter Type Remarks
field string Keyword to identify the field.
Not case-sensitive.

The associated label, aria-label, placeholder, adjacent text, and current value can be used to identify a field.
CSS and XPATH selectors can also be used, but is not recommended as it makes the tests harder to keep up to date.

Returns: The value of the input element

# Using field label

You can use the field's <label>, aria-label, placeholder, value, name, and nearby text to identify the field.

I.fill("Search", "Hello")
I.type(" from the other side") 
var searchTerm = I.getValue("Search") // This will be "Hello from the other side"

This command gets the value of the input field identified as "Search" and sets it to the variable searchTerm.

# Using field CSS / XPATH

You can also use CSS and XPATH to identify the field.

var email = I.getValue(".input-email")

This command gets the value of the input field with the CSS class input-email and sets it to the variable email.

Use sparingly.
Use hard selectors like CSS / XPATH sparingly because it makes your tests fragile and harder to read and maintain.