docs/src/api/class-androiddevice.md
[AndroidDevice] represents a connected device, either real hardware or emulated. Devices can be obtained using [method: Android.devices].
Emitted when the device connection gets closed.
Emitted when a new WebView instance is detected.
Disconnects from the device.
Drags the widget defined by [param: selector] towards [param: dest] point.
selector <[AndroidSelector]>Selector to drag.
dest <[Object]>
x <[float]>y <[float]>Point to drag to.
speed <[float]>Optional speed of the drag in pixels per second.
Fills the specific [param: selector] input box with [param: text].
selector <[AndroidSelector]>Selector to fill.
text <[string]>Text to be filled in the input box.
Flings the widget defined by [param: selector] in the specified [param: direction].
selector <[AndroidSelector]>Selector to fling.
direction <[AndroidFlingDirection]<"down"|"up"|"left"|"right">>Fling direction.
speed <[float]>Optional speed of the fling in pixels per second.
Returns information about a widget defined by [param: selector].
selector <[AndroidSelector]>Selector to return information about.
Installs an apk on the device.
file <[string]|[Buffer]>Either a path to the apk file, or apk file content.
args <[Array]<[string]>>Optional arguments to pass to the shell:cmd package install call. Defaults to -r -t -S.
Launches Chrome browser on the device, and returns its persistent context.
pkg <[string]>Optional package name to launch instead of default Chrome for Android.
Performs a long tap on the widget defined by [param: selector].
selector <[AndroidSelector]>Selector to tap on.
Device model.
Launches a process in the shell on the device and returns a socket to communicate with the launched process.
command <[string]>Shell command to execute.
Pinches the widget defined by [param: selector] in the closing direction.
selector <[AndroidSelector]>Selector to pinch close.
percent <[float]>The size of the pinch as a percentage of the widget's size.
speed <[float]>Optional speed of the pinch in pixels per second.
Pinches the widget defined by [param: selector] in the open direction.
selector <[AndroidSelector]>Selector to pinch open.
percent <[float]>The size of the pinch as a percentage of the widget's size.
speed <[float]>Optional speed of the pinch in pixels per second.
Presses the specific [param: key] in the widget defined by [param: selector].
selector <[AndroidSelector]>Selector to press the key in.
key <[AndroidKey]>The key to press.
Copies a file to the device.
file <[string]|[Buffer]>Either a path to the file, or file content.
path <[string]>Path to the file on the device.
mode <[int]>Optional file mode, defaults to 644 (rw-r--r--).
Returns the buffer with the captured screenshot of the device.
path <[path]>The file path to save the image to. If [option: path] is a
relative path, then it is resolved relative to the current working directory. If no path is provided, the image won't be
saved to the disk.
Scrolls the widget defined by [param: selector] in the specified [param: direction].
selector <[AndroidSelector]>Selector to scroll.
direction <[AndroidScrollDirection]<"down"|"up"|"left"|"right">>Scroll direction.
percent <[float]>Distance to scroll as a percentage of the widget's size.
speed <[float]>Optional speed of the scroll in pixels per second.
Device serial number.
This setting will change the default maximum time for all the methods accepting [param: timeout] option.
timeout <[float]>Maximum time in milliseconds
Executes a shell command on the device and returns its output.
command <[string]>Shell command to execute.
Swipes the widget defined by [param: selector] in the specified [param: direction].
selector <[AndroidSelector]>Selector to swipe.
direction <[AndroidSwipeDirection]<"down"|"up"|"left"|"right">>Swipe direction.
percent <[float]>Distance to swipe as a percentage of the widget's size.
speed <[float]>Optional speed of the swipe in pixels per second.
Taps on the widget defined by [param: selector].
selector <[AndroidSelector]>Selector to tap on.
duration <[float]>Optional duration of the tap in milliseconds.
Waits for the specific [param: selector] to either appear or disappear, depending on the [option: state].
selector <[AndroidSelector]>Selector to wait for.
state <[AndroidDeviceState]<"gone">>Optional state. Can be either:
'gone' - wait for element to not be present.Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.
optionsOrPredicate ?<[function]|[Object]>
predicate <[function]> receives the event data and resolves to truthy value when the waiting should resolve.timeout ?<[float]> maximum time to wait for in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to
disable timeout. The default value can be changed by using the [method: AndroidDevice.setDefaultTimeout].Either a predicate that receives an event or an options object. Optional.
This method waits until [AndroidWebView] matching the [param: selector] is opened and returns it. If there is already an open [AndroidWebView] matching the [param: selector], returns immediately.
selector <[Object]>
pkg ?<[string]> Optional Package identifier.socketName ?<[string]> Optional webview socket name.Currently open WebViews.