Support autoGrantPermissions and autoAcceptAlerts for handling native popups
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- android, ios, playwright, typescript
- Ambito
- mobile-dev, testing-qa
Direzione di ricerca
Start by reading the project’s configuration and app-launch paths, then trace how its Android and iOS agents interact with system alerts; the issue does not name specific files or tests. The proposed behavior spans config inheritance and distinct platform implementations, with real-device permission prompts requiring on-device detection. Done means both options work per project and per test across iOS and Android, with the stated defaults and selective permission behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem or motivation
When testing real apps, almost every first-launch flow is blocked by native OS prompts — runtime permission dialogs (location, camera, notifications, photos, microphone), system consent sheets, and app-level modals (cookie banners, onboarding, "Rate us").
Today there is no first-class way to handle these in mobilewright. Each test has to:
- Wait for the prompt to render,
- Locate the "Allow" / "OK" / "Don't Allow" button by text or role,
- Tap it,
- Repeat for every permission the app requests on launch.
This is boilerplate every test author rewrites, it's fragile (button text varies by OS version and locale — "Allow Once" vs "Allow While Using App" vs "OK"), and on simulators/emulators the same prompt fires every fresh install. Appium addresses this with autoAcceptAlerts / autoGrantPermissions capabilities; mobilewright currently does not.
Without a built-in mechanism, the realistic alternatives are:
- Pre-grant via
adb shell pm grant(Android) orxcrun simctl privacy grant(iOS simulator) — covers only manifest-declared OS permissions, doesn't help on iOS real devices, doesn't cover app-level modals. - Manual tap chains in every test — repetitive, breaks under OS-version drift.
Proposed solution
Two complementary additions:
1. autoGrantPermissions — automatically accept OS runtime permission prompts on test startup.
// In playwright.config.ts equivalent / project config
export default defineConfig({
use: {
autoGrantPermissions: true,
// or selective:
autoGrantPermissions: ['camera', 'location', 'notifications'],
},
});
Behavior:
true→ accept all OS permission prompts when they appear.string[]→ accept only the listed services; ignore the rest (test author handles them explicitly or fails on timeout).- Default
false→ no change from current behavior.
2. autoAcceptAlerts / autoDismissAlerts — handle generic alert/confirm/permission popups during the test.
export default defineConfig({
use: {
autoAcceptAlerts: true, // tap the primary affirmative button
// or
autoDismissAlerts: true, // tap the cancel/secondary button
},
});
Behavior:
true→ on any alert that appears mid-test, automatically tap the affirmative (accept) or secondary (dismiss) button.- Default
false.
Both options should be configurable per-test (test.use({ autoAcceptAlerts: true })) and per-project, matching Playwright's config inheritance.
Expected ergonomics: a test that today reads —
await device.launchApp('com.example.app');
await screen.getByText('Allow').tap(); // location prompt
await screen.getByText('Allow').tap(); // notifications
await screen.getByText('Continue').tap(); // onboarding
await screen.getByText('Find nearby').tap();
— becomes:
// config: autoGrantPermissions: true
await device.launchApp('com.example.app');
await screen.getByText('Find nearby').tap();
Target platform
Platform-agnostic
Alternatives considered
1. adb shell pm grant / xcrun simctl privacy grant documented as the recommended approach. Rejected as the primary solution:
- Doesn't work on iOS real devices.
- Only covers OS runtime permissions, not app-level modals (cookie banners, in-app consent, "Rate us" prompts).
- Pushes platform-specific shell-out into every user's test setup.
Still worth shipping as an optional helper for the predictable-permission case, but not a substitute.
2. Document a "tap the button by role" recipe and leave it to test authors. Rejected — that's what users do today, and it's exactly the boilerplate this issue exists to remove. It also doesn't survive OS-version button-label changes.
3. Add a single coarse autoAcceptAlerts: true capability (Appium-style) without autoGrantPermissions. Workable for a first iteration, but coarse — it would also accept destructive prompts ("Delete all photos?"). Better to split permissions from generic alerts so users can opt into the safe subset.
Additional context
Target platform
Both iOS and Android. The implementation paths differ:
- Android —
autoGrantPermissionscan be implemented cheaply viaadb shell pm grantat app-launch time for manifest-declared runtime permissions.autoAcceptAlertsneeds on-device detection (UiAutomatorUiWatcheror equivalent). - iOS simulator —
autoGrantPermissionsviaxcrun simctl privacy grant. - iOS real device — no OS-level escape hatch; both options require on-device detection through the agent (XCUITest, similar to Appium's
FBAlertsMonitor).
This RFC requests the feature surface; the implementation strategy per platform can be settled during design.
Additional context
- Appium's prior art:
autoAcceptAlerts/autoDismissAlertscapabilities and the on-device implementation inFBAlertsMonitor.m. - Reproduction app for the iOS permission-prompt flow: Playground v1.0.3 (shared by @Gil Megidish in the related Slack discussion).
- Playwright analogue for shape comparison:
page.on('dialog')— same surface area (programmatic accept/dismiss), different transport assumptions.
- Lingua principale
- TypeScript
- Stelle
- 411
- Fork
- 66
- Merge medio
- 2g 1h
- PR unite (30g)
- 56
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mobile-next/mobilewright
-
Locator.fill()/clear() fails on iOS fieldsForse già presa @esge l’ha presa 8 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
mobile-next/mobilewright#404 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[OOT] Python SDK supportAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
mobile-next/mobilewright#428 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
mobile-next/mobilewright#426 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
mobile-next/mobilewright#425 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
mobile-next/mobilewright#424 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di mobile-next/mobilewright
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
logto-io/logto#9837 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
lingdojo/kana-dojo#32964 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Documentation status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
mastra-ai/mastra#28194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
priority-low refactor-3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 3 giorni