Class: Playwright::Android

Inherits:
PlaywrightApi show all
Defined in:
lib/playwright_api/android.rb

Overview

Playwright has experimental support for Android automation. This includes Chrome for Android and Android WebView.

Requirements

*Known limitations*

  • Raw USB operation is not yet supported, so you need ADB.

  • Device needs to be awake to produce screenshots. Enabling “Stay awake” developer mode will help.

  • We didn’t run all the tests against the device, so not everything works.

*How to run*

An example of the Android automation script would be:

Note that since you don’t need Playwright to install web browsers when testing Android, you can omit browser download via setting the following environment variable when installing Playwright:

“‘bash js PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright “`

Instance Method Summary collapse

Methods inherited from PlaywrightApi

#initialize, unwrap, wrap

Constructor Details

This class inherits a constructor from Playwright::PlaywrightApi

Instance Method Details

#connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil) ⇒ Object

This methods attaches Playwright to an existing Android device. Use [‘method: Android.launchServer`] to launch a new Android server instance.

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/playwright_api/android.rb', line 30

def connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil)
  raise NotImplementedError.new('connect is not implemented yet.')
end

#devices(host: nil, omitDriverInstall: nil, port: nil) ⇒ Object

Returns the list of detected Android devices.



36
37
38
# File 'lib/playwright_api/android.rb', line 36

def devices(host: nil, omitDriverInstall: nil, port: nil)
  wrap_impl(@impl.devices(host: unwrap_impl(host), omitDriverInstall: unwrap_impl(omitDriverInstall), port: unwrap_impl(port)))
end

#off(event, callback) ⇒ Object

– inherited from EventEmitter –



49
50
51
# File 'lib/playwright_api/android.rb', line 49

def off(event, callback)
  event_emitter_proxy.off(event, callback)
end

#on(event, callback) ⇒ Object

– inherited from EventEmitter –



61
62
63
# File 'lib/playwright_api/android.rb', line 61

def on(event, callback)
  event_emitter_proxy.on(event, callback)
end

#once(event, callback) ⇒ Object

– inherited from EventEmitter –



55
56
57
# File 'lib/playwright_api/android.rb', line 55

def once(event, callback)
  event_emitter_proxy.once(event, callback)
end

#set_default_timeout(timeout) ⇒ Object Also known as: default_timeout=

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

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/playwright_api/android.rb', line 42

def set_default_timeout(timeout)
  raise NotImplementedError.new('set_default_timeout is not implemented yet.')
end