Class: Playwright::Android
- Inherits:
-
PlaywrightApi
- Object
- PlaywrightApi
- Playwright::Android
- Defined in:
- lib/playwright_api/android.rb
Overview
Playwright has experimental support for Android automation. This includes Chrome for Android and Android WebView.
Requirements
- Android device or AVD Emulator.
- ADB daemon running and authenticated with your device.
Typically running
adb devicesis all you need to do. Chrome 87or 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:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
Instance Method Summary collapse
-
#devices(host: nil, omitDriverInstall: nil, port: nil) ⇒ Object
Returns the list of detected Android devices.
-
#off(event, callback) ⇒ Object
-- inherited from EventEmitter --.
-
#on(event, callback) ⇒ Object
-- inherited from EventEmitter --.
-
#once(event, callback) ⇒ Object
-- inherited from EventEmitter --.
-
#set_default_timeout(timeout) ⇒ Object
(also: #default_timeout=)
This setting will change the default maximum time for all the methods accepting
timeoutoption.
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#devices(host: nil, omitDriverInstall: nil, port: nil) ⇒ Object
Returns the list of detected Android devices.
29 30 31 |
# File 'lib/playwright_api/android.rb', line 29 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 --
41 42 43 |
# File 'lib/playwright_api/android.rb', line 41 def off(event, callback) event_emitter_proxy.off(event, callback) end |
#on(event, callback) ⇒ Object
-- inherited from EventEmitter --
53 54 55 |
# File 'lib/playwright_api/android.rb', line 53 def on(event, callback) event_emitter_proxy.on(event, callback) end |
#once(event, callback) ⇒ Object
-- inherited from EventEmitter --
47 48 49 |
# File 'lib/playwright_api/android.rb', line 47 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.
34 35 36 |
# File 'lib/playwright_api/android.rb', line 34 def set_default_timeout(timeout) raise NotImplementedError.new('set_default_timeout is not implemented yet.') end |