Validate Element Attribute (Mobile)

Validate any element attribute in your mobile app

The element attribute validation allows you to validate the value of attributes within your app screen elements.

Adding a Validate Element Attribute step

To add a Validate Element Attribute step:

  1. Hover over the (arrow symbol) where you want to add the validation.

The action options are displayed.

  1. Click on the Toggle breakpoint button.

  1. Click on the Run test button, to run the test until the breakpoint.

  1. Hover over the (arrow symbol) again and click on the “M” (Testim predefined steps).
    The Predefined steps menu opens.

  1. Click on Validations. The Validations menu expands. Scroll down through the menu and select Validate element attribute.

📘

Alternatively, you can use the search box at the top of the menu to search for Validate element attribute.

  1. In the AUT window, identify the relevant element for which you wish to validate an element attribute, and click on it to select it. You will need to know the element's attribute name to configure the validation.

  1. The Element Attribute Validation form is shown.

  1. In the Attribute name field, enter a valid element attribute name that you wish to validate (e.g. checkable, checked, className, clickable). For a list of possible attributes, see, List of possible attributes.
  2. In the Expected value field, enter the value you wish to validate for the attribute (e.g. true).

📘

When modifying the value of the Attribute name and Expected value in the Properties panel, make sure they are enclosed in single quotes: e.g. ‘enabled’ and ‘true`.

📘

For the expected value you can use regex.

Testim will validate whether the selected element attribute's expected value is present when running your test.

  1. Click OK. The “Validate element attribute” step is added in the Editor, and a thumbnail of the selected element is shown in the step.
  2. Click on the Toggle Breakpoint button after the validation step to remove the breakpoint.

Modifying a Validate element attribute step

If you want to change the element you selected, you don’t need to delete and re-record the step. Instead, you can reassign the element with a different element. Alternatively, you can modify the attribute name and/or expected value of the original element you selected without selecting a new element.

To reassign the selected element in a Validation step:

  1. Hover over the position to the left of the step for which you want to reassign the element and click on the Toggle breakpoint button.
  2. Click on the Run test button to run the test until the breakpoint.
  3. Hover over the step for which you want to reassign the element and click on the Show Properties () icon.

The Properties panel opens on the right-hand side.

  1. Hover over the Target element thumbnail to show options, and click Reassign.

  1. In the AUT window, identify the new element that you would like to select and click on it.
    The selected element is shown in the Target element box in the Properties panel.
  2. In the Properties panel Attribute name field enter the attribute name for the new element.
  3. In the Properties panel Expected value field enter the expected value of the new attribute.

📘

When modifying the value of the Attribute name and Expected value in the Properties panel, make sure they are enclosed in single quotes: e.g. 'enabled' and 'true'.

  1. Click on the same Toggle Breakpoint button to the left of the step for which you reassigned the element to remove the breakpoint.

To modify the properties of the original element:

  1. Hover over the step for which you want to reassign the element and click on the Show Properties () icon.

The Properties panel opens on the right-hand side.

  1. In the Properties panel Attribute name field enter the new attribute name for the element.
  2. In the Properties panel Expected value field enter the new expected value of the attribute.

📘

When modifying the value of the Attribute name and Expected value in the Properties panel, make sure they are enclosed in single quotes: e.g. ‘clickable’ and 'true'.

List of possible attributes

iOS attributes (using Appium)

  • checkable
  • checked
  • {class,className}
  • clickable {content-desc,contentDescription}
  • enabled
  • focusable
  • focused
  • {long-clickable,longClickable}
  • package
  • password
  • {resource-id,resourceId}
  • scrollable
  • selection-start
  • selection-end
  • selected
  • {text,name}
  • hint
  • extras
  • bounds
  • displayed
  • contentSize

Android attributes

  • UID
  • accessibilityContainer
  • accessible
  • enabled
  • frame
  • index
  • label
  • name
  • rect
  • selected
  • type
  • value
  • visible
  • wdAccessibilityContainer
  • wdAccessible
  • wdEnabled
  • wdFrame
  • wdIndex
  • wdLabel
  • wdName
  • wdRect
  • wdSelected
  • wdType
  • wdUID
  • wdValue
  • wdVisible