class Playwright::Android
Playwright
has experimental support for Android
automation. This includes Chrome for Android
and Android
WebView.
Requirements
-
Android
device or AVD Emulator. -
[ADB daemon](developer.android.com/studio/command-line/adb) running and authenticated with your device. Typically running `adb devices` is all you need to do.
-
[`Chrome 87`](play.google.com/store/apps/details?id=com.android.chrome) or newer installed on the device
-
“Enable command line on non-rooted devices” enabled in `chrome://flags`.
*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 “`
Public Instance Methods
Returns the list of detected Android
devices.
# File lib/playwright_api/android.rb, line 29 def devices wrap_impl(@impl.devices) end
– inherited from EventEmitter
– @nodoc
# File lib/playwright_api/android.rb, line 53 def off(event, callback) event_emitter_proxy.off(event, callback) end
– inherited from EventEmitter
– @nodoc
# File lib/playwright_api/android.rb, line 47 def on(event, callback) event_emitter_proxy.on(event, callback) end
– inherited from EventEmitter
– @nodoc
# File lib/playwright_api/android.rb, line 41 def once(event, callback) event_emitter_proxy.once(event, callback) end
This setting will change the default maximum time for all the methods accepting `timeout` option.
# File lib/playwright_api/android.rb, line 34 def set_default_timeout(timeout) raise NotImplementedError.new('set_default_timeout is not implemented yet.') end
Private Instance Methods
# File lib/playwright_api/android.rb, line 57 def event_emitter_proxy @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl) end