Skip to content

Element Attributes

The XCUITest driver supports various native and custom element attributes.

type

Example: XCUIElementTypeButton

Corresponds to the element's XCTest elementType value.

name

Example: hello

Corresponds to the element's XCTest identifier or label property, depending on which one is available first. Can be null.

For developers, it is recommended to use accessibilityIdentifier over accessibilityLabel for automation purposes, since the identifier property is supposed to stay constant under different locales, and does not affect accessibility services such as VoiceOver.

In applications written using React Native, this attribute corresponds to the testID property.

label

Examples: hello, hello\nworld

Corresponds to the element's XCTest label value. Can be null.

value

Example: hello

This is a complex attribute whose calculation algorithm depends on the actual element type. Check WebDriverAgent sources to know more about how it is compiled (method - (NSString *)wdValue). Can be null.

placeholderValue

Example: Placeholder text

Corresponds to the element's XCTest placeholderValue value.

minValue

Examples: 0, 0.0, 1

Returns the element's minimum allowed value, typically for controls like sliders or progress indicators.

This attribute is not included in the default page source due to performance reasons, but it can be added by changing the includeMinMaxValueInPageSource setting to true, or retrieved using the Get Element Attribute API.

maxValue

Examples: 100, 1.0

Returns the element's maximum allowed value, typically for controls like sliders or progress indicators.

This attribute is not included in the default page source due to performance reasons, but it can be added by changing the includeMinMaxValueInPageSource setting to true, or retrieved using the Get Element Attribute API.

enabled

Example: false

Corresponds to the element's XCTest enabled value.

selected

Example: false

Corresponds to the element's XCTest selected value.

focused

Example: true

Corresponds to the element's XCTest hasFocus value.

hittable

Example: true

Corresponds to the element's XCTest isHittable value.

This attribute is not included in the default page source due to performance reasons, but it can be added by changing the includeHittableInPageSource setting to true, or retrieved using the Get Element Attribute API.

Note that isHittable requires an element to have the isAccessibilityElement property enabled. This means that if the element is on screen, but it sets accessibilityElementsHidden to false, then hittable will be set to false.

visible

Example: false

Returns whether the element is visible. This value is not available in XCTest and is read directly from the accessibility layer.

accessible

Example: false

Returns whether the element is accessible. This value is not available in XCTest and is read directly from the accessibility layer.

index

Example: 2

Returns the element's index in the hierarchy relatively to its parent. Indexing starts from 0.

rect

Example: {"x": 0,"y": 0,"width": 100,"height": 100}

Returns the element's position and dimensions. Based on the element's XCTest frame value.

traits

Examples: Button, Adjustable, Button

Returns an comma-separated string of the element's XCTest UIAccessibilityTraits constants.

customActions

Example: Action 1,Action 2

Returns a comma-separated string of custom accessibility actions attached to the element. Based on the element's accessibilityAction and UIAccessibilityCustomAction values.

This attribute is not included in the default page source due to performance reasons, but it can be added by changing the includeCustomActionsInPageSource setting to true, or retrieved using the Get Element Attribute API.