setValue, whatever library draws them. adjustSlider drags a slider’s thumb like a
finger, and accessibilityAction does what a screen reader does. Like every action, they wait for the app
to be idle before and after (every call waits) and take the
call options.
Setting a value
setValue(target, value, options?)
MatcherInput · ActionOptions · ElementSummary
Sets the control at target to value: a number, a boolean, a string or a Date. It uses real input
where the control has it (a tap on a switch, iOS wheels turned by a finger, a browser <select>), and the
component’s callbacks otherwise.
Which controls it knows
setValue looks at the props of the component around the target: the element itself and a few levels up.
If there is none, it takes the single control inside the element — for example a View that carries the
testID around a component that drops it.
- Setting the value the control already has sends no event.
- A disabled control is left alone, as it would be for a user.
- Anything else fails with
ACTION_NOT_SUPPORTED. The message names the callbacks that were found and what was searched: the components going up from the target (with the props that decide a control’s kind), and the control-shaped components inside it with why each was not taken (more than 8 levels above its element, or one of several controls). From that, move the testID, wrap the control, or use a backdoor.
How the value gets in
Android’s
DateTimePicker renders no view: it opens a system dialog. So once the app shows it,
setValue({ id }) finds the component itself by its testID (or { type: 'DateTimePicker' } by its
name). The app closes the dialog when it handles the change, as it would for the user’s choice. Only the
id, type and index matchers reach such components.
Date and time pickers
Like the native dialogs,setValue changes only the part of the picker’s value that its mode shows,
in the picker’s time zone (timeZoneOffsetInMinutes, else the device’s):
So picking a date and then a time on Android’s two dialogs keeps the date:
minimumDate/maximumDateare checked against the result.- The strings are local time on the device, so they do not depend on the host’s time zone. A
Dateis converted to the device’s time zone.
Reading a picker’s value
A picker’s value (expectValue, the value of a
query) is what it shows, in local time on the device: "2031-12-24" (date), "20:15"
(time), "2031-12-24T20:15" (datetime, countdown), with :ss when the seconds are not 0.
expectValue takes that string, or a Date that matches when those parts agree.
@expo/ui’s DateTimePicker
@expo/ui/community/datetime-picker (SwiftUI on iOS, Jetpack Compose on Android) takes the same values.
Put the testID on the DateTimePicker itself:
- iOS, and Android with
presentation="inline": the view that gets thetestIDreports no size to React Native, although the picker is drawn. Quiesco checks visibility on its nearest ancestor that has a size (theHost, or its parent when theHostis 0 wide underalignItems: 'center'). - Android dialogs (the default
presentation): thetestIDis not passed on to any view. Quiesco finds theDateTimePickerby its owntestIDprop, as it does for@react-native-community/datetimepickeron Android.
setValue calls the picker’s onValueChange / onChange in every mode; it does not scroll the wheels. On
the web the component renders nothing.
Sliders
adjustSlider(target, position, options?)
MatcherInput · ActionOptions · ElementSummary
Drags the slider’s thumb to position, from 0 (the minimum) to 1 (the maximum), with a real finger or
mouse. Use it when the test should exercise the drag itself; setValue sets an exact value instead.
nativemode: the thumb follows the finger less the touch slop, so Quiesco reads the value back and drags again (always one way, with a run-up) until the slider is within one step (1% of a continuous slider’s range) of the position.- Web: a mouse drag of the thumb.
jsmode: the value at that position, through the callbacks.
Accessibility actions
accessibilityAction(target, name, options?)
MatcherInput · ActionOptions · ElementSummary
Performs the accessibility action name, as a screen reader does. It acts on the target or the nearest
ancestor that declares accessibilityActions; the target does not have to be on screen.
name must be one the element declares; otherwise the error lists the declared ones. How the action is
performed: