Version: 1.10.0

AndroidDevice

AndroidDevice represents a connected device, either real hardware or emulated. Devices can be obtained using android.devices().

androidDevice.on('webview')#

Emitted when a new WebView instance is detected.

androidDevice.close()#

Disconnects from the device.

androidDevice.drag(selector, dest[, options])#

Drags the widget defined by selector towards dest point.

androidDevice.fill(selector, text[, options])#

  • selector <[AndroidSelector]> Selector to fill.
  • text <string> Text to be filled in the input box.
  • options <Object>

Fills the specific selector input box with text.

androidDevice.fling(selector, direction[, options])#

  • selector <[AndroidSelector]> Selector to fling.
  • direction <"down"|"up"|"left"|"right"> Fling direction.
  • options <Object>

Flings the widget defined by selector in the specified direction.

androidDevice.info(selector)#

  • selector <[AndroidSelector]> Selector to return information about.
  • returns: <Promise<[AndroidElementInfo]>>

Returns information about a widget defined by selector.

androidDevice.installApk(file[, options])#

  • file <string|Buffer> Either a path to the apk file, or apk file content.
  • options <Object>
    • args <Array<string>> Optional arguments to pass to the shell:cmd package install call. Defaults to -r -t -S.

Installs an apk on the device.

androidDevice.launchBrowser([options])#

  • options <Object>
    • acceptDownloads <boolean> Whether to automatically download all the attachments. Defaults to false where all the downloads are canceled.
    • bypassCSP <boolean> Toggles bypassing page's Content-Security-Policy.
    • colorScheme <"light"|"dark"|"no-preference"> Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'. See page.emulateMedia([options]) for more details. Defaults to 'light'.
    • command <string> Optional package name to launch instead of default Chrome for Android.
    • deviceScaleFactor <number> Specify device scale factor (can be thought of as dpr). Defaults to 1.
    • extraHTTPHeaders <Object<string, string>> An object containing additional HTTP headers to be sent with every request. All header values must be strings.
    • geolocation <Object>
      • latitude <number> Latitude between -90 and 90.
      • longitude <number> Longitude between -180 and 180.
      • accuracy <number> Non-negative accuracy value. Defaults to 0.
    • hasTouch <boolean> Specifies if viewport supports touch events. Defaults to false.
    • httpCredentials <Object> Credentials for HTTP authentication.
    • ignoreHTTPSErrors <boolean> Whether to ignore HTTPS errors during navigation. Defaults to false.
    • isMobile <boolean> Whether the meta viewport tag is taken into account and touch events are enabled. Defaults to false. Not supported in Firefox.
    • javaScriptEnabled <boolean> Whether or not to enable JavaScript in the context. Defaults to true.
    • locale <string> 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.
    • logger <Logger> Logger sink for Playwright logging.
    • offline <boolean> Whether to emulate network being offline. Defaults to false.
    • permissions <Array<string>> A list of permissions to grant to all pages in this context. See browserContext.grantPermissions(permissions[, options]) for more details.
    • recordHar <Object> 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.
      • omitContent <boolean> Optional setting to control whether to omit request content from the HAR. Defaults to false.
      • path <string> Path on the filesystem to write the HAR file to.
    • recordVideo <Object> 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.
      • dir <string> Path to the directory to put videos into.
      • size <Object> 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.
        • width <number> Video frame width.
        • height <number> Video frame height.
    • timezoneId <string> Changes the timezone of the context. See ICU's metaZones.txt for a list of supported timezone IDs.
    • userAgent <string> Specific user agent to use in this context.
    • videoSize <Object> DEPRECATED Use recordVideo instead.
      • width <number> Video frame width.
      • height <number> Video frame height.
    • videosPath <string> DEPRECATED Use recordVideo instead.
    • viewport <null|Object> Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. null disables the default viewport.
      • width <number> page width in pixels.
      • height <number> page height in pixels.
  • returns: <Promise<ChromiumBrowserContext>>

Launches Chrome browser on the device, and returns its persistent context.

androidDevice.longTap(selector[, options])#

Performs a long tap on the widget defined by selector.

androidDevice.model()#

Device model.

androidDevice.open(command)#

Launches a process in the shell on the device and returns a socket to communicate with the launched process.

androidDevice.pinchClose(selector, percent[, options])#

  • selector <[AndroidSelector]> Selector to pinch close.
  • percent <number> The size of the pinch as a percentage of the widget's size.
  • options <Object>

Pinches the widget defined by selector in the closing direction.

androidDevice.pinchOpen(selector, percent[, options])#

  • selector <[AndroidSelector]> Selector to pinch open.
  • percent <number> The size of the pinch as a percentage of the widget's size.
  • options <Object>

Pinches the widget defined by selector in the open direction.

androidDevice.press(selector, key[, options])#

  • selector <[AndroidSelector]> Selector to press the key in.
  • key <[AndroidKey]> The key to press.
  • options <Object>

Presses the specific key in the widget defined by selector.

androidDevice.push(file, path[, options])#

  • file <string|Buffer> Either a path to the file, or file content.
  • path <string> Path to the file on the device.
  • options <Object>
    • mode <number> Optional file mode, defaults to 644 (rw-r--r--).

Copies a file to the device.

androidDevice.screenshot([options])#

  • options <Object>
    • path <string> 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: <Promise<Buffer>>

Returns the buffer with the captured screenshot of the device.

androidDevice.scroll(selector, direction, percent[, options])#

  • selector <[AndroidSelector]> Selector to scroll.
  • direction <"down"|"up"|"left"|"right"> Scroll direction.
  • percent <number> Distance to scroll as a percentage of the widget's size.
  • options <Object>

Scrolls the widget defined by selector in the specified direction.

androidDevice.serial()#

Device serial number.

androidDevice.setDefaultTimeout(timeout)#

  • timeout <number> Maximum time in milliseconds

This setting will change the default maximum time for all the methods accepting timeout option.

androidDevice.shell(command)#

Executes a shell command on the device and returns its output.

androidDevice.swipe(selector, direction, percent[, options])#

  • selector <[AndroidSelector]> Selector to swipe.
  • direction <"down"|"up"|"left"|"right"> Swipe direction.
  • percent <number> Distance to swipe as a percentage of the widget's size.
  • options <Object>

Swipes the widget defined by selector in the specified direction.

androidDevice.tap(selector[, options])#

  • selector <[AndroidSelector]> Selector to tap on.
  • options <Object>

Taps on the widget defined by selector.

androidDevice.wait(selector[, options])#

  • selector <[AndroidSelector]> Selector to wait for.
  • options <Object>
    • state <"gone"> Optional state. Can be either:
      • default - wait for element to be present.
      • 'gone' - wait for element to not be present.
    • timeout <number> Maximum time in milliseconds, defaults to 30 seconds, pass 0 to disable timeout. The default value can be changed by using the androidDevice.setDefaultTimeout(timeout) method.

Waits for the specific selector to either appear or disappear, depending on the state.

androidDevice.waitForEvent(event[, optionsOrPredicate])#

  • event <string> Event name, same one typically passed into *.on(event).
  • optionsOrPredicate <function|Object> Either a predicate that receives an event or an options object. Optional.
    • predicate <function> receives the event data and resolves to truthy value when the waiting should resolve.
    • timeout <number> 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(timeout).
  • returns: <Promise<Object>>

Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.

androidDevice.webView(selector[, options])#

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.

androidDevice.webViews()#

Currently open WebViews.

androidDevice.input#