Defines various ways to select an element on the page. At least one selector option (selector, xpath, text, role, etc.) must be provided. These options are used by queries like element and mutations like click, fill, etc.

Definition

input ElementOptions {
  selector: String
  xpath: String
  text: String
  role: String
  label: String
  placeholder: String
  altText: String
  title: String
  testId: String
}

Fields

selector

String A CSS selector. Example: "div.item[data-id='123']" or "#submitButton".

xpath

String An XPath selector. Example: //button[@id='submit']. While the generic selector field can also accept XPath prefixed with xpath=, this xpath field is dedicated exclusively to XPath expressions.

text

String Matches elements by their exact or partial text content. Case-sensitive. Example: "Login" or "Add to Cart"

role

String Matches elements by their ARIA role. Example: "button", "link", "navigation".

label

String Matches elements by their ARIA label. Example: "Close notification".

placeholder

String Matches input elements by their placeholder attribute. Example: "Enter your username".

altText

String Matches <img> elements by their alt attribute. Example: "User profile picture".

title

String Matches elements by their title attribute. Example: "Click to learn more".

testId

String Matches elements by their ‘data-testid’ attribute, commonly used for testing. Example: "login-form-submit".