Karagöz
v0.5.1Device automation for Android emulators and phones, iOS simulators and iPhones.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
devices List devices
List Android devices and emulators, running iOS simulators, and iPhones connected to this Mac.
screenshot Take a screenshot
Save a full-resolution PNG of the screen and return its path with size, scale and safe area. Use ui_tree to read the screen; inline only to look at the image.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
inline | boolean | Also return the image. Take coordinates from ui_tree, not from the image. |
out | string | Absolute PNG path, ending in .png. Default: a new temp file. |
ui_tree Read the UI tree
Return the focused window's accessibility tree as JSON, compact by default: nodes with no text, label or action and nodes off screen are left out. Node bounds [left, top, right, bottom] are the physical pixels tap and swipe take. On an iPhone it needs karagoz's runner: install it once with install_runner.
| Parameter | Type | Description |
|---|---|---|
detail | string | full: every node. |
device | string | Id or name. |
tap Tap
Tap x, y in physical pixels, or the center of the node whose text or contentDesc (iOS: label or value) equals text, or whose resource id (iOS: identifier) matches id. An iPhone needs install_runner once.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
id | string | Resource id, full or the part after :id/ (iOS: identifier). |
text | string | Exact text or contentDesc (iOS: label or value), case-sensitive. |
timeout | integer | With text or id: ms to keep reading the tree until the node appears; the call can run up to 6 s longer. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
x | number | |
y | number |
long_press Long-press
Long-press x, y in physical pixels, or the center of the node whose text or contentDesc (iOS: label or value) equals text, or whose resource id (iOS: identifier) matches id. An iPhone needs install_runner once.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
duration | integer | Hold time in ms. Default 1000. |
id | string | Resource id, full or the part after :id/ (iOS: identifier). |
text | string | Exact text or contentDesc (iOS: label or value), case-sensitive. |
timeout | integer | With text or id: ms to keep reading the tree until the node appears; the call can run up to 6 s longer. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
x | number | |
y | number |
double_tap Double-tap
Double-tap x, y in physical pixels, or the center of the node whose text or contentDesc (iOS: label or value) equals text, or whose resource id (iOS: identifier) matches id. An iPhone needs install_runner once.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
id | string | Resource id, full or the part after :id/ (iOS: identifier). |
text | string | Exact text or contentDesc (iOS: label or value), case-sensitive. |
timeout | integer | With text or id: ms to keep reading the tree until the node appears; the call can run up to 6 s longer. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
x | number | |
y | number |
swipe Swipe
Swipe from x1, y1 to x2, y2 in physical pixels. An iPhone needs install_runner once.
| Parameter | Type | Description |
|---|---|---|
x1 * | number | |
x2 * | number | |
y1 * | number | |
y2 * | number | |
device | string | Id or name. |
duration | integer | ms from start to end. Default 300. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
text Type text
Type into the focused field. Any text; on Android, text beyond ASCII is pasted through the clipboard and the old clip put back. An iPhone needs install_runner once.
| Parameter | Type | Description |
|---|---|---|
text * | string | |
device | string | Id or name. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
key Press a key
Press one key.
| Parameter | Type | Description |
|---|---|---|
key * | string | KeyEvent name (HOME, BACK, KEYCODE_7) or code 1-340; "7" is code 7 (KEYCODE_0), not the digit. iOS takes HOME, POWER, VOLUME_UP/DOWN and keyboard keys; an iPhone only keys that type a character, and n… |
device | string | Id or name. |
tree | boolean | Also return the screen once it settles, as ui_tree does. treeError means only that read failed; the action ran. |
install Install an app
Install an .apk, or a .app or .ipa on an iOS simulator or iPhone, or replace the installed version of the same app. An iPhone takes only a build signed for it; karagoz does not re-sign. Times out after 30 s plus 1 s per MB.
| Parameter | Type | Description |
|---|---|---|
apk * | string | Absolute path to the .apk, .app or .ipa. |
device | string | Id or name. |
launch Launch an app
Start an app as its launcher icon does. On iOS it returns before the app is in front.
| Parameter | Type | Description |
|---|---|---|
package * | string | |
device | string | Id or name. |
open_url Open a URL
Open a URL in the app that handles it, or in the app named by app. On iOS it returns before the app is in front, and a simulator may first ask "Open in <app>?".
| Parameter | Type | Description |
|---|---|---|
url * | string | |
app | string | Package name or bundle id; not on an iOS simulator. |
device | string | Id or name. |
terminate Stop an app
Force-stop every process of an app.
| Parameter | Type | Description |
|---|---|---|
package * | string | |
device | string | Id or name. |
uninstall Uninstall an app
Remove an app.
| Parameter | Type | Description |
|---|---|---|
package * | string | |
device | string | Id or name. |
logs Read device logs
Read the newest device log records, oldest first. On iOS without since: the last minute, or the last hour with package. An iPhone read takes about 10 s.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
lines | integer | Number of newest records. Default 30. |
package | string | Only this app's records. |
since | number | Unix seconds on the device clock; only later records. Pass a record's time to continue. |
doctor Check adb and Xcode
Report which adb and Xcode tools karagoz uses, their versions, and how to fix one that is missing, old or broken.
install_runner Install karagoz's iPhone runner
Build karagoz's runner with your Apple team and install it on a paired iPhone over USB; ui_tree, tap, swipe, text and key need it there.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |
team | string | Apple team ID; needed only when Xcode lists several. |
uninstall_runner Remove karagoz's iPhone runner
Remove karagoz's runner and its provisioning profile from an iPhone.
| Parameter | Type | Description |
|---|---|---|
device | string | Id or name. |