Skip to content

fix(wda): leave a prompt only to the step aimed at it, as DeviceLab's driver does - #265

Open
luka-vladika-happening-xyz wants to merge 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-prompt-tap-keeps-other-prompts-answered
Open

luka-vladika-happening-xyz wants to merge 1 commit into
devicelab-dev:mainfrom
luka-vladika-happening-xyz:fix/wda-prompt-tap-keeps-other-prompts-answered

Conversation

@luka-vladika-happening-xyz

@luka-vladika-happening-xyz luka-vladika-happening-xyz commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Follows #264, fixed in 1.1.31 by d75c50d (this PR's first commit). Rebased onto main, so this is the second commit alone.

With 1.1.31 a lookup that finds nothing answers a prompt the flow does not tap, so the notification prompt no longer stays up for the whole flow. It still answers late: a tap that meets the prompt is lost under it, and the flow then waits out a lookup for what the lost tap should have opened (about 20 s on an onboarding).

The change: when the flow turned WDA's alert monitor off, the driver answers prompts as DeviceLab's driver does: a prompt is left only to the step aimed at it, and answered before any other step acts, as the monitor would have.

  • Aimed at it (stepAimsAtAlert): a tap, double tap or long press on one of its buttons (pickAlertButton, as a tap would pick it), a check of one of its buttons or of its text (assertVisible, assertNotVisible, copyTextFrom, extendedWaitUntil). A flow with acceptAlert / dismissAlert keeps every prompt to itself, as today.
  • Answered (answerUnnamedPrompt): the button the monitor's autoClickAlertSelector would have tapped (Allow…; or Don't Allow… / Ask App Not… for all: deny), checked closed (answerAlert), one log line.
  • When: a tap asks after its find, while a watch is open (15 s after launchApp, 3 s after an answered prompt, at most every 0.5 s), answers, and finds its element again. A lookup that finds nothing asks at most once a second. Asking after the find matters: an alert check sent while the app was still launching held WebDriverAgent for 19 s on a busy simulator, and a find answers only once the app does.

What stays: a flow with no prompt tap keeps WDA's monitor and pays nothing. The common "if the prompt shows, tap Don't Allow" (runFlow with when: visible) still answers the prompt itself when it runs while the prompt is up: its condition finds the prompt's button, and its tap is aimed at it. A tap on the app that meets the prompt first gets it answered as the permissions say, as with DeviceLab's driver.

Cost: only in flows that tap a prompt's button: one /alert/text (60-80 ms on a light page, about 0.3 s on a heavy one), plus /wda/alert/buttons when an alert is up, at the taps in the watch and on lookups that miss.

Tests: TestLookupLeavesThePromptToTheStepAimedAtIt, TestLookupAnswersAPromptTheFlowAnswersElsewhere, TestTapAnswersAnUnnamedPromptFirst, TestTapAsksForNoAlertWhenWDAAnswers, TestTapAsksForPromptsOnlyInTheWatch. go test -race ./pkg/driver/wda/ ./pkg/executor/ ./pkg/flow/ passes; golangci-lint v2.13.2: 0 issues.

On devices: five real iPhones (iOS 18.3 to 27.2), 20 flows of our suite that tap the tracking prompt's button themselves and leave the notification prompt to the runner: no prompt stayed up in 300 flow runs, and the three onboarding flows took 24 s at the median, against 44 s with the first commit (now d75c50d) alone. On simulators (--driver wda, iOS 27, six at once) the onboarding flows take 16-17 s, against 34-46 s before and 14-15 s with DeviceLab's driver.

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.93443% with 22 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/driver/wda/alert.go 63.26% 16 Missing and 2 partials ⚠️
pkg/driver/wda/commands.go 42.85% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@luka-vladika-happening-xyz

luka-vladika-happening-xyz commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor Author

I pushed a second commit after running this on simulators and five real iPhones. Answering a prompt only when a lookup misses came too late, in two ways:

  • A tap under the prompt is lost. WebDriverAgent's tree is the app's, so the find for the onboarding's "OK" succeeds in the app beneath the notification prompt, and the tap goes to the prompt. The next lookup misses and answers it, and the flow's retry has to tap again.
  • The prompt the flow names elsewhere waits for the flow. Our onboarding taps "Ask App Not to Track" in an optional step of a retry, so the tracking prompt stayed up through the onboarding's 10 s wait for the next screen, twice, before the retry reached that step.

The commit leaves a prompt only to the step aimed at it, as DeviceLab's driver does (aimsAtAlert): a tap on one of its buttons or a check of its text. Any other step gets it answered as launchApp's permissions say. A tap asks for an alert after its find, in a watch of 15 s after launchApp and 3 s after an answered prompt, and answers it before tapping. A lookup that misses still asks, at most once a second.

On five real iPhones (iOS 18.3, 18.4, 26.2, 27.0 and 27.2), 20 flows of our suite, three rounds alternating with a build that has the first commit only (the build with this commit also had the settle fix of #269):

  • The three flows that onboard took 24 s instead of 44 s at the median, and no flow stopped behind a prompt.
  • Alert checks fell from 35 to 20 a flow, since a miss no longer asks on every poll. Each check is a bit slower (median 0.38 s against 0.26 s): more of them now come at taps on heavy pages.
  • The tracking prompt was answered "Allow" (launchApp's default permissions) in 90 flow runs, where the first commit left it to the flow's optional "Ask App Not to Track", which the onboarding reached only after waiting behind the prompt. A step aimed at a prompt still answers it itself when it is the step running; an earlier tap that meets the prompt gets it answered as the permissions say, as with DeviceLab's driver.

On simulators with --driver wda the same three flows went from 34-46 s to 16-17 s at six simulators at once.

omnarayan pushed a commit that referenced this pull request Nov 12, 2026
…hers answered (#265)

Since a flow that taps a prompt's button turns WDA's alert monitor off for
the whole session (so WDA cannot beat the flow to it), a prompt the flow never
meant to answer stayed up over the app: a flow that taps "Ask App Not to
Track" left the notification prompt open, and every later lookup failed.

A lookup that finds nothing now reads the open alert and, when none of its
buttons is one the flow's taps name and the flow has no acceptAlert or
dismissAlert, answers it as WDA's monitor would have (launchApp's
permissions: the "Allow…" button, or "Don't Allow…" / "Ask App Not…"),
then looks again. The prompts the flow names are still left to it.
Refs #264
… driver does

When the flow answers some permission prompts itself (WDA's monitor off),
a prompt is now left only to the step aimed at it (a tap on one of its
buttons, a check of its text), not to every step of a flow that names one
of its buttons somewhere, and it is asked for by a tap after its find, in a
watch after launchApp (15 s) and after an answered prompt (3 s), as well as
by a lookup that misses (at most once a second). A tap under the
notification prompt was lost, since its element was found in the app
beneath the prompt, and the tracking prompt held the onboarding's 10 s wait
for the screen beneath it until the flow's retry tapped it. Asked before
the find, the check could hold WebDriverAgent for 19 s while the app was
still launching.
@luka-vladika-happening-xyz
luka-vladika-happening-xyz force-pushed the fix/wda-prompt-tap-keeps-other-prompts-answered branch from 79f1e8a to 779c67b Compare November 13, 2026 07:34
@luka-vladika-happening-xyz luka-vladika-happening-xyz changed the title fix(wda): a flow that answers one permission prompt still gets the others answered fix(wda): leave a prompt only to the step aimed at it, as DeviceLab's driver does Nov 13, 2026
@luka-vladika-happening-xyz

Copy link
Copy Markdown
Contributor Author

Rebased onto main after 1.1.31: the first commit is in main as d75c50d, so this PR is now the second one alone (a prompt left only to the step aimed at it, answered before a tap rather than after a lookup misses). Its code is as before, merged with #269's settle in driver.go; the title and description now describe just this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants