looktap v0.10.0

Agents

Examples

Tests in CI, recording a flow, screenshot sweeps and running on several devices are in Tests and automation.

Look, then act

looktap ls
@1   Button           16, 285 358x54  General
@2   Button           16, 339 358x54  Accessibility
@3   TextField        33, 773 324x38  Search  = Search

Each row shows a ref (@1), the element type, its x,y position and width×height (iOS points / Android dp, the units tapxy and swipe take), its label, and = value for fields that hold text and for switches and checkboxes (1 on, 0 off). Unlabelled buttons are listed too, as (no label), so you can tap them by ref. The on-screen keyboard is a single row.

Tap by label, not by coordinates

looktap tap "Open menu"              # exact label (or identifier on iOS)
# tapped "Open menu" at 30,62
looktap tap "Messages"               # no exact match → the one label starting with it
# tapped "Messages, 2 unread" at 342,62
looktap tap "Wi"                     # matches two different labels → refuses
# looktap: "Wi" is ambiguous — matches 2 labels: "Wi-Fi", "Wi-Fi hotspot"
looktap tap --exact "Messages"       # exact only
looktap tap @7                       # row @7 of the last ls
looktap tapxy 205 874                # when ls doesn't list it at all

Long press and pinch-zoom

looktap longpress "Photo"               # context menus, drag handles, "edit" modes (default 800 ms)
looktap longpress @4 1500               # by ref, held 1.5 s
looktap longpress 120 470               # a point, e.g. to drop a pin on a map
looktap zoom in                         # two fingers spreading at the screen centre (maps, photos, PDFs)
looktap zoom out 200 400 --scale 4      # pinch around a point; --scale is how far the fingers travel

zoom is a real two-finger gesture on both platforms. On Android it needs looktap's helper, because adb input has no multi-touch.

Fill a form and capture its validation errors

looktap fill "Email" not-an-email
looktap fill "Name" ""               # empty: just clears the field
looktap hidekb
looktap shot profile__validation

fill finds the field by its label (on iOS also its identifier), or else the first field at or below a matching label. It clears the field and types, then reads the field back. Keys can get lost (a field that was still clearing swallows the first letters; a web field drops keys while WebKit autocorrects), so on a miss it empties the field and types again key by key, then, on the iOS simulator, pastes the text, and fails rather than report a value the field doesn't hold. A field that formats its input (spaces, a currency sign, a capital) passes. A password field shows dots, so its length is what's checked. On Android it also presses Enter, because React Native fields only show validation on blur.

A one-time code split across boxes goes in with code:

looktap code 540390

It finds the row of boxes, taps only the first and types the digits one at a time, pausing while the boxes move focus along (tapping every box too puts digits a box off). Then it reads every box. If they don't hold the code, it taps each box before its digit, then pastes the code into the first; it fails listing what each box holds if none of that works.

On iOS, hidekb tries, in order:

  1. the keyboard's Done/Return key;
  2. the ✓ on a web form's Previous/Next bar;
  3. a tap on plain text above the keyboard.

On Android it takes focus from the field, as a tap outside it would (so a form that validates on blur shows its errors), and presses Back only if the keyboard is still up. It checks after each. If the keyboard is still up, it exits 2 rather than reporting success.

Wait instead of sleeping, and scroll

looktap wait "Welcome"                  # until it's on screen (default up to 10 s; --wait 30)
looktap wait "Loading" --gone           # until it's gone
looktap wait --settle                   # a web page with no labels: until the screen, picture too, holds still
looktap scrollto "Privacy & Security"   # swipe until fully on screen; fails at the end of the list
looktap scrollto "General" --up
looktap swipe 200 700 200 250           # scroll down (finger moves up); optional 5th arg: ms
looktap back                            # Android: system Back · iOS: the navigation bar's back button
looktap home                            # the Home button: home screen, the app keeps running

Debug: logs, crashes, "where did my app go?"

looktap tap "Pay"                       # something goes wrong…
looktap logs --errors                   # the app's errors since the last `logs`
# 15:41:06.700 E [com.example:api] POST /payments failed: 422 amount_too_small
looktap logs --grep payment             # everything it logged that matches
looktap app --app com.example           # is it still running?
# front: com.android.launcher3  pid 1205
# com.example: not running — if it was, check: looktap crashes
looktap crashes
# com.example (pid 14001) exited at 14:56:06.724 while in the background: LOW_MEMORY — killed by the system to free memory, not a crash

When the app dies, looktap says so. After an action, and at the next ls, looktap checks whether the app that was in front still has its process. If not, it prints:

looktap: warning: com.example is no longer running — it crashed or was killed. See: looktap crashes com.example

Each logs call starts where the previous one ended, so a loop of act → logs only ever shows what's new. --since 5m sets a fixed window instead.

What's in the log:

What crashes reports:

React Native: in development builds, JS console.* output and uncaught JS errors are in logs on both platforms:

A red box is also on screen, so ls reads its message and call stack.

Swift: print() writes to stdout, not to the log. Use os.Logger or NSLog for messages logs should see.

Performance: CPU, memory, frames, launch time

looktap launch com.example --time       # a cold start, timed
# launched com.example: in front after 0.44 s, first screen settled by 0.85 s · Android TotalTime 300 ms
looktap perf                            # the app in front: one reading
# com.example  pid 4127
# cpu      14%  (over 0.5 s; 100% is one core)
# memory   pss 78.4 MB · rss 171.2 MB · java heap 12.1 MB · native heap 18.6 MB
# threads  21
looktap perf --for 20s                  # a reading each second while you (or a flow) use the app, then avg/max
looktap perf --frames                   # frames since the last --frames, janky %, p50–p99 frame time (iOS simulator:
                                        # the first call starts counting)
looktap swipe 200 700 200 200; looktap perf --frames   # how smooth was that scroll?

Catch a spinner, toast, or transition (burst)

Start the burst in the background, then trigger the action:

looktap burst ./frames 5 &              # 5 s: a frame each time the screen changes
looktap swipe 200 250 200 700           # pull to refresh
wait
# 61 frames, 23 distinct, in ./frames

For a video of a whole flow, record it. The recording runs in the background between the two commands:

looktap record start checkout           # → ./shots/checkout.mp4
looktap tap "Add to cart" --ls
looktap tap "Checkout" --ls
looktap record stop                     # prints the path and the length

Show where it taps (touches)

A recording of an agent's run shows screens changing with no sign of what was touched. touches on draws a pointer on the device wherever a touch lands: a dot while the finger is down, a fading trail behind a swipe, two dots for a pinch, and a ring that lingers for a moment after a quick tap. While it's touching, the inside edge of the screen glows in looktap's accent colour, and fades about a second after the last touch, so a glance tells you looktap is driving.

looktap touches on                      # touches: on
looktap record start checkout
looktap tap "Add to cart"               # the video shows the pointer on the button
looktap swipe 200 600 200 300
looktap record stop
looktap touches off

The pointer is on the device's own screen, so record, shot, burst and a person watching all see it. It stays out of the app's way: it takes no touches and isn't in what ls reads. Nothing is installed.

DeviceWhat shows the pointerHow
Android emulator or phonelooktap's touches, in every app and on the home screenlooktap's helper draws on a display layer of its own (Android 10+). It's there only while a pointer is on screen
iOS simulatorEvery app started after touches on, and the home screen and system alerts. A mouse click in the Simulator window shows tooA small library is loaded into the simulator's apps and draws inside each one. The home screen restarts once so it has it, which closes the apps; an app already running needs looktap launch again
Real iPhone or iPadOnly your own app, built with one extra file; and in looktap live, over the phone's picture for any appiOS lets nothing draw over another app or load into one. Add native/ios-touches/LooktapTouches.m (looktap touches on prints its path) to your app's target for Debug builds; it draws nothing until looktap launch starts the app with touches on. The live page draws every agent touch itself, from where looktap noted it landed

Watch every device in your browser (live)

looktap live
# looktap live: http://127.0.0.1:4470/

Open that address. Every running simulator, emulator and connected phone is on one canvas, each in a phone's frame, showing its screen as it changes. Run your agent or your flows in another terminal and watch all the devices at once. The chips along the top take a device off the canvas or put it back, and the zoom fits them to the window. A device that starts later appears by itself, and with touches on the pointer and the glow show here too.

Control. Switch on Control in the page and it drives the devices:

In the pageOn the device
ClickTap
Click and holdLong press
DragThe finger moves as the mouse does: swipe, scroll, drag a slider
Mouse wheel or trackpad scrollScrolls
Typing, Enter, Backspace, Tab, Escape, pasteTyped into the device you last touched
Home and Back under each phoneHome, and Android's Back

With touches on, your clicks and drags show the pointer on the device but not the glow: the glow is what says an agent is driving. A real iPhone can't draw either, so the page draws them over its picture as an agent taps, presses or swipes it (looktap notes each touch in its activity log as it sends it).

While the page is touching a device it holds that device the way a looktap command does, so it and an agent don't both act at once: if an agent is mid-command, the page says who has the device and the touch is dropped, and the other way round. It lets go two seconds after your last action.

DeviceHow it's shownNotes
Android emulator or phoneThe device's own video encoder, passed through and decoded by the browserSmooth (the phone's frame rate). Needs a browser with WebCodecs: current Chrome, Edge or Safari. Screens an app marks secure are black, as in any recording
iOS simulatorA picture each time the screen changes, from looktap's helperUp to 30 frames a second, at half resolution
Real iPhone or iPad on a USB cableVideo: the phone's screen feed, the one QuickTime usesUp to 30 frames a second. The phone must be unlocked, and nothing else may be using the feed (QuickTime, perf --frames); while it isn't available the phone is shown as on Wi-Fi
Real iPhone or iPad on Wi-FiScreenshots through looktap's runnerAbout 5 a second: iOS gives the Mac no video of a phone's screen over the network. Plug it in for video

On a real iPhone, a tap, long press or swipe is sent when you release the mouse, not as you drag, and there is no Back button (iOS has none). The first time, the runner is built and signed, as for any looktap command on one.

Under each device:

Start and shut down simulators and emulators from the page, with Control on: the Start picker in the top bar lists the iOS simulators and Android emulators that aren't running, and starts the one you pick headless (you watch it here); its tile appears once it's up. Shut down under a simulator or emulator stops it after a second click. If an agent is using it at that moment, the page says who and leaves it running. Real phones have neither.

Troubleshoot (top right, with Control on) is for a device that's slow or stuck. It works for a device with no picture too, the stuck one above all: with Control on, its name along the top opens it. It shows the way to the device (an Android phone's USB round trip and whether it's also on Wi-Fi; an iPhone's USB, Wi-Fi and CoreDevice tunnel), switches for Wireless debugging, Keep it on and Keep the screen on on an Android phone (an iPhone's last round trip to its runner instead), and everything holding the device, as looktap who <device> lists it: what's in use, what's left over, what stays. Then Restart looktap's helper (or an iPhone's runner session), Clear left-overs (release --all) and Stop everything (release --all --force, after a second click). Every fix shows in Activity. It asks the device on a thread of its own, so the other pictures don't stall while a stuck link takes its time.

Activity (top right) lists every looktap command as it runs, from any terminal, agent, MCP client or the page itself, with the device, how long it took, and why it failed when it did. looktap keeps them in ~/.looktap/activity.jsonl (at most 512 KB: it drops its older half past that). Typed text (type, paste, fill, code) is written only as its length, never the text.

When a device is slow, stuck or held

looktap doctor -d R83Y30R6V6M            # the way to it, layer by layer, and what to do
looktap who R83Y30R6V6M                  # everything holding it
looktap release R83Y30R6V6M --all        # clear the left-overs, so the next command starts clean

A slow link isn't a stuck one. Each Android command probes the way to the phone first. A round trip over 3 s gets a warning and longer timeouts for every adb call (three round trips each, up to 2 minutes): commands crawl, but they work. Past the adb timeout plus 5 s (20 s; LOOKTAP_ADB_TIMEOUT raises it) the link counts as stalled, and the error says what didn't answer, for how long, and that it's the link, not the adb server. A phone that's on Wi-Fi as well (looktap wifi, the cable can stay in) is driven over Wi-Fi by itself while USB is slow or stalled, still under its USB serial: hubs and worn cables are the usual cause, and Wi-Fi usually answers at once. doctor -d shows whether it does, and --fix only restarts adb when a restart can help.

looktap who <device> lists everything holding a device (an Android phone, an iPhone or a simulator), each with its pid, how long it has run, what started it, and whether it's in use or left over:

ItemAndroidiPhone and simulator
looktapcommands holding it, live streaming it, mcp; its helper on the phone and the adb forward to itcommands holding it, live, mcp; the runner session (xcodebuild test-without-building, or testmanagerd on iOS 16 and older; older ones marked replaced), the simulator helper
Left behindadb calls whose parent is gone, or that have run for 10 minutes without streamingsimctl and devicectl calls the same way
Other toolsscrcpy, Appium, Maestro, Android Studio; on the phone Appium's servers, Maestro, scrcpy's server, a uiautomator dumpWebDriverAgent, Maestro, iproxy, pymobiledevice3 or go-ios tunnels, idb, Instruments
The way to itadb forwards and reverses, the USB serial and the Wi-Fi id of the same phoneUSB (usbmuxd), Wi-Fi, the CoreDevice tunnel

iOS gives the Mac no list of a phone's processes, so another tool's runner on an iPhone shows as its session on the Mac. Holds whose process is gone are cleared as who runs.

looktap release <device> --all clears what nobody is using and says each thing it did: dead holds, the calls left behind, and looktap's own way in when no looktap command is running (its helper and forwards on an Android phone, an iPhone's runner sessions, the simulator helper). The next command starts them fresh. It keeps the adb reverse rules (Metro), the looktap runner app, and the CoreDevice tunnel (macOS's, shared with Xcode). What someone may be using, another agent mid-command, live streaming the device, or any tool that isn't looktap, is listed and left alone; --force stops it too, after asking (--yes: without). The same is in looktap live's Troubleshoot panel and, for whoever holds an Android phone, in the runner app's Troubleshoot card.

Errors name what's in the way. A busy device names the command holding it, its pid, and release --all --force for when that session is gone. A stalled link names the adb calls left waiting on it. An Android helper that won't answer names Appium or another tool on the phone. An iPhone runner that won't start names WebDriverAgent, Maestro or an older looktap session holding the phone (only one UI test session can drive an iPhone).

Start from a clean state: install, reset, permissions

looktap install build/MyApp.app          # iOS: a simulator build · Android: an .apk (keeps the app's data)
# installed com.example.myapp
looktap reset com.example.myapp          # as if freshly installed: data and permissions cleared
looktap permission grant location com.example.myapp    # no prompt
looktap permission revoke photos com.example.myapp     # test the "denied" path
looktap permission reset camera com.example.myapp      # it asks again on next use
looktap stop com.example.myapp          # end it; prints "stopped" once its process is gone
looktap uninstall com.example.myapp

Simulated conditions: location, dark mode, text size, orientation, network, push, notifications

looktap location 51.5072 -0.1276        # GPS (Android phones: test providers) · `location clear` · prints "location set"
looktap route --from-current --bearing 90 --distance 630m --speed 1.4 --step 5s --then-still 7m   # walk out of a geofence
looktap appearance dark                 # or light; no argument prints the current one
looktap textsize ax2                    # Dynamic Type / font scale: xs s m l xl xxl xxxl ax1…ax5
looktap statusbar clean                 # 9:41, full battery and Wi-Fi, for screenshots · `statusbar live`
looktap rotate landscape --ls           # or left, right, upsidedown, portrait; no argument prints it
looktap fold open --ls                  # a foldable (iPhone Duo): closed, half or open; no argument prints it
looktap network offline                 # Android: airplane mode · `network online`
looktap push com.example.myapp "Your order has shipped"          # iOS: an alert
looktap push com.example.myapp '{"aps":{"alert":"Hi"},"orderId":7}'   # or any payload / a .json file
looktap notifications                   # what arrived: Notification Center / the shade, newest first
looktap notifications com.example.myapp --until "has shipped"    # wait for it (up to --wait, default 30 s)

Biometrics

looktap bio match       # iOS: Face ID success · Android: enrolled finger 1
looktap bio nomatch     # iOS: Face ID failure · Android: unknown finger

On Android, enrol a fingerprint once first: Settings → Security → Fingerprint, using a screen-lock PIN, and touch with looktap bio match when it asks.

Android screenshots of secure screens

Apps that set FLAG_SECURE (common in banking and payment apps) make normal Android screenshots come out black. On emulators, looktap shot takes the frame from the emulator itself, which gets past that. --plain takes a normal on-device screenshot, for example to check that a screen is secure.

Generated from README.md. Edit it there.