AndroidDevice
Source URL: https://playwright.dev/docs/api/class-androiddevice
AndroidDevice | Playwright
Section titled “AndroidDevice | Playwright”AndroidDevice represents a connected device, either real hardware or emulated. Devices can be obtained using android.devices().
Methods
Section titled “Methods”Added in: v1.9 androidDevice.close
Disconnects from the device.
Usage
await androidDevice.close();Returns
Added in: v1.9 androidDevice.drag
Drags the widget defined by selector towards dest point.
Usage
await androidDevice.drag(selector, dest); await androidDevice.drag(selector, dest, options);Arguments
selector[AndroidSelector]#
Selector to drag.
Point to drag to.
Optional speed of the drag in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-drag-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.fill
Fills the specific selector input box with text.
Usage
await androidDevice.fill(selector, text); await androidDevice.fill(selector, text, options);Arguments
selector[AndroidSelector]#
Selector to fill.
Text to be filled in the input box.
Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.fling
Flings the widget defined by selector in the specified direction.
Usage
await androidDevice.fling(selector, direction); await androidDevice.fling(selector, direction, options);Arguments
selector[AndroidSelector]#
Selector to fling.
direction“down” | “up” | “left” | “right”#
Fling direction.
Optional speed of the fling in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-fling-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.info
Returns information about a widget defined by selector.
Usage
await androidDevice.info(selector);Arguments
selector[AndroidSelector]#
Selector to return information about.
Returns
installApk
Section titled “installApk”Added in: v1.9 androidDevice.installApk
Installs an apk on the device.
Usage
await androidDevice.installApk(file); await androidDevice.installApk(file, options);Arguments
Either a path to the apk file, or apk file content.
Optional arguments to pass to the shell:cmd package install call. Defaults to -r -t -S.
Returns
launchBrowser
Section titled “launchBrowser”Added in: v1.9 androidDevice.launchBrowser
Launches Chrome browser on the device, and returns its persistent context.
Usage
await androidDevice.launchBrowser(); await androidDevice.launchBrowser(options);Arguments
Whether to automatically download all the attachments. Defaults to true where all the downloads are accepted.
* `args` [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array")<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")> _(optional)_ Added in: v1.29[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-args)warning
Use custom browser args at your own risk, as some of them may break Playwright functionality.
Additional arguments to pass to the browser instance. The list of Chromium flags can be found here.
* `baseURL` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-base-url)When using page.goto(), page.route(), page.waitForURL(), page.waitForRequest(), or page.waitForResponse() it takes the base URL in consideration by using the URL() constructor for building the corresponding URL. Unset by default. Examples:
* baseURL: `http://localhost:3000` and navigating to `/bar.html` results in `http://localhost:3000/bar.html` * baseURL: `http://localhost:3000/foo/` and navigating to `./bar.html` results in `http://localhost:3000/foo/bar.html` * baseURL: `http://localhost:3000/foo` (without trailing slash) and navigating to `./bar.html` results in `http://localhost:3000/bar.html`* `bypassCSP` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-bypass-csp)Toggles bypassing page’s Content-Security-Policy. Defaults to false.
* `colorScheme` [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null") | "light" | "dark" | "no-preference" _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-color-scheme)Emulates prefers-colors-scheme media feature, supported values are 'light' and 'dark'. See page.emulateMedia() for more details. Passing null resets emulation to system defaults. Defaults to 'light'.
* `contrast` [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null") | "no-preference" | "more" _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-contrast)Emulates 'prefers-contrast' media feature, supported values are 'no-preference', 'more'. See page.emulateMedia() for more details. Passing null resets emulation to system defaults. Defaults to 'no-preference'.
* `deviceScaleFactor` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-device-scale-factor)Specify device scale factor (can be thought of as dpr). Defaults to 1. Learn more about emulating devices with device scale factor.
* `extraHTTPHeaders` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object")<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string"), [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")> _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-extra-http-headers)An object containing additional HTTP headers to be sent with every request. Defaults to none.
* `forcedColors` [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null") | "active" | "none" _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-forced-colors)Emulates 'forced-colors' media feature, supported values are 'active', 'none'. See page.emulateMedia() for more details. Passing null resets emulation to system defaults. Defaults to 'none'.
* `geolocation` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-geolocation)
* `latitude` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Latitude between -90 and 90.
* `longitude` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Longitude between -180 and 180.
* `accuracy` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_Non-negative accuracy value. Defaults to 0.
* `hasTouch` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-has-touch)Specifies if viewport supports touch events. Defaults to false. Learn more about mobile emulation.
* `httpCredentials` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-http-credentials)
* `username` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")
* `password` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")
* `origin` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_Restrain sending http credentials on specific origin (scheme://host:port).
* `send` "unauthorized" | "always" _(optional)_This option only applies to the requests sent from corresponding APIRequestContext and does not affect requests sent from the browser. 'always' - Authorization header with basic authentication credentials will be sent with the each API request. 'unauthorized - the credentials are only sent when 401 (Unauthorized) response with WWW-Authenticate header is received. Defaults to 'unauthorized'.
Credentials for HTTP authentication. If no origin is specified, the username and password are sent to any servers upon unauthorized responses.
* `ignoreHTTPSErrors` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-ignore-https-errors)Whether to ignore HTTPS errors when sending network requests. Defaults to false.
* `isMobile` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-is-mobile)Whether the meta viewport tag is taken into account and touch events are enabled. isMobile is a part of device, so you don’t actually need to set it manually. Defaults to false and is not supported in Firefox. Learn more about mobile emulation.
* `javaScriptEnabled` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-java-script-enabled)Whether or not to enable JavaScript in the context. Defaults to true. Learn more about disabling JavaScript.
* `locale` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-locale)Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language request header value as well as number and date formatting rules. Defaults to the system default locale. Learn more about emulation in our emulation guide.
* `logger` [Logger](https://playwright.dev/docs/api/class-logger "Logger") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-logger)Deprecated
The logs received by the logger are incomplete. Please use tracing instead.
Logger sink for Playwright logging.
* `offline` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-offline)Whether to emulate network being offline. Defaults to false. Learn more about network emulation.
* `permissions` [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array "Array")<[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")> _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-permissions)A list of permissions to grant to all pages in this context. See browserContext.grantPermissions() for more details. Defaults to none.
* `pkg` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-pkg)Optional package name to launch instead of default Chrome for Android.
* `proxy` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_ Added in: v1.29[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-proxy)
* `server` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")Proxy to be used for all requests. HTTP and SOCKS proxies are supported, for example http://myproxy.com:3128 or socks5://myproxy.com:3128. Short form myproxy.com:3128 is considered an HTTP proxy.
* `bypass` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_Optional comma-separated domains to bypass proxy, for example ".com, chromium.org, .domain.com".
* `username` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_Optional username to use if HTTP proxy requires authentication.
* `password` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_Optional password to use if HTTP proxy requires authentication.
Network proxy settings.
* `recordHar` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-record-har)
* `omitContent` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_Optional setting to control whether to omit request content from the HAR. Defaults to false. Deprecated, use content policy instead.
* `content` "omit" | "embed" | "attach" _(optional)_Optional setting to control resource content management. If omit is specified, content is not persisted. If attach is specified, resources are persisted as separate files or entries in the ZIP archive. If embed is specified, content is stored inline the HAR file as per HAR specification. Defaults to attach for .zip output files and to embed for all other file extensions.
* `path` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")Path on the filesystem to write the HAR file to. If the file name ends with .zip, content: 'attach' is used by default.
* `mode` "full" | "minimal" _(optional)_When set to minimal, only record information necessary for routing from HAR. This omits sizes, timing, page, cookies, security and other types of HAR information that are not used when replaying from HAR. Defaults to full.
* `urlFilter` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") | [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp "RegExp") _(optional)_A glob or regex pattern to filter requests that are stored in the HAR. When a baseURL via the context options was provided and the passed URL is a path, it gets merged via the new URL() constructor. Defaults to none.
Enables HAR recording for all pages into recordHar.path file. If not specified, the HAR is not recorded. Make sure to await browserContext.close() for the HAR to be saved.
* `recordVideo` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-record-video)
* `dir` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string")Path to the directory to put videos into.
* `size` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_
* `width` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Video frame width.
* `height` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Video frame height.
Optional dimensions of the recorded videos. If not specified the size will be equal to viewport scaled down to fit into 800x800. If viewport is not configured explicitly the video size defaults to 800x450. Actual picture of each page will be scaled down if necessary to fit the specified size.
Enables video recording for all pages into recordVideo.dir directory. If not specified videos are not recorded. Make sure to await browserContext.close() for videos to be saved.
* `reducedMotion` [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null") | "reduce" | "no-preference" _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-reduced-motion)Emulates 'prefers-reduced-motion' media feature, supported values are 'reduce', 'no-preference'. See page.emulateMedia() for more details. Passing null resets emulation to system defaults. Defaults to 'no-preference'.
* `screen` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-screen)
* `width` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")page width in pixels.
* `height` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")page height in pixels.
Emulates consistent window screen size available inside web page via window.screen. Is only used when the viewport is set.
* `serviceWorkers` "allow" | "block" _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-service-workers)Whether to allow sites to register Service workers. Defaults to 'allow'.
* `'allow'`: [Service Workers](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be registered. * `'block'`: Playwright will block all registration of Service Workers.* `strictSelectors` [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type "Boolean") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-strict-selectors)If set to true, enables strict selectors mode for this context. In the strict selectors mode all operations on selectors that imply single target DOM element will throw when more than one element matches the selector. This option does not affect any Locator APIs (Locators are always strict). Defaults to false. See Locator to learn more about the strict mode.
* `timezoneId` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-timezone-id)Changes the timezone of the context. See ICU’s metaZones.txt for a list of supported timezone IDs. Defaults to the system timezone.
* `userAgent` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-user-agent)Specific user agent to use in this context.
* `videoSize` [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-video-size)Deprecated
Use recordVideo instead.
* `width` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Video frame width.
* `height` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")Video frame height.
* `videosPath` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-videos-path)Deprecated
Use recordVideo instead.
* `viewport` [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null "null") | [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object "Object") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-launch-browser-option-viewport)
* `width` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")page width in pixels.
* `height` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number")page height in pixels.
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. Use null to disable the consistent viewport emulation. Learn more about viewport emulation.
note
The null value opts out from the default presets, makes viewport depend on the host window size defined by the operating system. It makes the execution of the tests non-deterministic.
Returns
longTap
Section titled “longTap”Added in: v1.9 androidDevice.longTap
Performs a long tap on the widget defined by selector.
Usage
await androidDevice.longTap(selector); await androidDevice.longTap(selector, options);Arguments
selector[AndroidSelector]#
Selector to tap on.
Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.model
Device model.
Usage
androidDevice.model();Returns
Added in: v1.9 androidDevice.open
Launches a process in the shell on the device and returns a socket to communicate with the launched process.
Usage
await androidDevice.open(command);Arguments
Shell command to execute.
Returns
pinchClose
Section titled “pinchClose”Added in: v1.9 androidDevice.pinchClose
Pinches the widget defined by selector in the closing direction.
Usage
await androidDevice.pinchClose(selector, percent); await androidDevice.pinchClose(selector, percent, options);Arguments
selector[AndroidSelector]#
Selector to pinch close.
The size of the pinch as a percentage of the widget’s size.
Optional speed of the pinch in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-pinch-close-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
pinchOpen
Section titled “pinchOpen”Added in: v1.9 androidDevice.pinchOpen
Pinches the widget defined by selector in the open direction.
Usage
await androidDevice.pinchOpen(selector, percent); await androidDevice.pinchOpen(selector, percent, options);Arguments
selector[AndroidSelector]#
Selector to pinch open.
The size of the pinch as a percentage of the widget’s size.
Optional speed of the pinch in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-pinch-open-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.press
Presses the specific key in the widget defined by selector.
Usage
await androidDevice.press(selector, key); await androidDevice.press(selector, key, options);Arguments
selector[AndroidSelector]#
Selector to press the key in.
key[AndroidKey]#
The key to press.
Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.push
Copies a file to the device.
Usage
await androidDevice.push(file, path); await androidDevice.push(file, path, options);Arguments
Either a path to the file, or file content.
Path to the file on the device.
Optional file mode, defaults to 644 (rw-r--r--).
Returns
screenshot
Section titled “screenshot”Added in: v1.9 androidDevice.screenshot
Returns the buffer with the captured screenshot of the device.
Usage
await androidDevice.screenshot(); await androidDevice.screenshot(options);Arguments
The file path to save the image to. If 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.
Returns
Added in: v1.9 androidDevice.scroll
Scrolls the widget defined by selector in the specified direction.
Usage
await androidDevice.scroll(selector, direction, percent); await androidDevice.scroll(selector, direction, percent, options);Arguments
selector[AndroidSelector]#
Selector to scroll.
direction“down” | “up” | “left” | “right”#
Scroll direction.
Distance to scroll as a percentage of the widget’s size.
Optional speed of the scroll in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-scroll-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.serial
Device serial number.
Usage
androidDevice.serial();Returns
setDefaultTimeout
Section titled “setDefaultTimeout”Added in: v1.9 androidDevice.setDefaultTimeout
This setting will change the default maximum time for all the methods accepting timeout option.
Usage
androidDevice.setDefaultTimeout(timeout);Arguments
Maximum time in milliseconds
Added in: v1.9 androidDevice.shell
Executes a shell command on the device and returns its output.
Usage
await androidDevice.shell(command);Arguments
Shell command to execute.
Returns
Added in: v1.9 androidDevice.swipe
Swipes the widget defined by selector in the specified direction.
Usage
await androidDevice.swipe(selector, direction, percent); await androidDevice.swipe(selector, direction, percent, options);Arguments
selector[AndroidSelector]#
Selector to swipe.
direction“down” | “up” | “left” | “right”#
Swipe direction.
Distance to swipe as a percentage of the widget’s size.
Optional speed of the swipe in pixels per second.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-swipe-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.tap
Taps on the widget defined by selector.
Usage
await androidDevice.tap(selector); await androidDevice.tap(selector, options);Arguments
selector[AndroidSelector]#
Selector to tap on.
Optional duration of the tap in milliseconds.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-tap-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
Added in: v1.9 androidDevice.wait
Waits for the specific selector to either appear or disappear, depending on the state.
Usage
await androidDevice.wait(selector); await androidDevice.wait(selector, options);Arguments
selector[AndroidSelector]#
Selector to wait for.
Optional state. Can be either:
* default - wait for element to be present. * `'gone'` \- wait for element to not be present.* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_[#](https://playwright.dev/docs/api/class-androiddevice#android-device-wait-option-timeout)Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
waitForEvent
Section titled “waitForEvent”Added in: v1.9 androidDevice.waitForEvent
Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.
Usage
await androidDevice.waitForEvent(event); await androidDevice.waitForEvent(event, optionsOrPredicate);Arguments
Event name, same one typically passed into *.on(event).
receives the event data and resolves to truthy value when the waiting should resolve.
* `timeout` [number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type "Number") _(optional)_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 androidDevice.setDefaultTimeout().
Either a predicate that receives an event or an options object. Optional.
Returns
webView
Section titled “webView”Added in: v1.9 androidDevice.webView
This method waits until AndroidWebView matching the selector is opened and returns it. If there is already an open AndroidWebView matching the selector, returns immediately.
Usage
await androidDevice.webView(selector); await androidDevice.webView(selector, options);Arguments
Optional Package identifier.
* `socketName` [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type "string") _(optional)_Optional webview socket name.
Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout() method.
Returns
webViews
Section titled “webViews”Added in: v1.9 androidDevice.webViews
Currently open WebViews.
Usage
androidDevice.webViews();Returns
Properties
Section titled “Properties”Added in: v1.9 androidDevice.input
Usage
androidDevice.inputType
on(‘close’)
Section titled “on(‘close’)”Added in: v1.28 androidDevice.on(‘close’)
Emitted when the device connection gets closed.
Usage
androidDevice.on('close', data => {});Event data
on(‘webview’)
Section titled “on(‘webview’)”Added in: v1.9 androidDevice.on(‘webview’)
Emitted when a new WebView instance is detected.
Usage
androidDevice.on('webview', data => {});Event data