Support autoGrantPermissions and autoAcceptAlerts for handling native popups
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- android, ios, playwright, typescript
- Área
- mobile-dev, testing-qa
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- TypeScript
- Estrellas
- 411
- Forks
- 66
- Merge medio
- 1 d 21 h
- PR fusionados (30 d)
- 61
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mobile-next/mobilewright
-
Locator.fill()/clear() fails on iOS fieldsPosiblemente ocupada @esge la tomó hace 7 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
mobile-next/mobilewright#404 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
mobile-next/mobilewright#426 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
mobile-next/mobilewright#425 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
mobile-next/mobilewright#424 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
mobile-next/mobilewright#412 ·
Los mantenedores suelen responder en 1 día
Todos los issues de mobile-next/mobilewright
Issues similares
-
agent/scanner help wanted hive/claimed-by-scanner kind/bug stage/020-claimed
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
hivecommons/rationguard#315 ·
Los mantenedores suelen responder en 1 día
-
agent-ready area: ui-sdk priority: p3 type: chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
schlessera/brain-kit#2534 ·
Los mantenedores suelen responder en 1 día
-
bug lane:gh-5
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
LLM-4-People/bridlewise-testing#122 ·
Los mantenedores suelen responder en 1 día
-
bug priority: P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
enhancement priority:low ready-for-dev
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día