arrow-left Back to topicQuizEmulationCheck yourself1.You want to run the same test on iPhone 13 and Desktop Chrome. What's the right approach?Create two projects in playwright.config.ts using devices['iPhone 13'] and devices['Desktop Chrome']Call page.setViewportSize() at the start of each testUse test.use({ isMobile: true }) inside a describe block2.Your app asks for notification permission on page load. The test fails because Playwright can't interact with the browser permission dialog. How do you fix it?Click the dialog with page.click() using a CSS selectorCall context.grantPermissions(['notifications']) before page.goto()Add a waitForTimeout(3000) to wait for the dialog to close3.What does a device profile (e.g., devices['iPhone 13']) set when used in a project?Only the viewport size.userAgent, viewport, deviceScaleFactor, hasTouch, and isMobile — all in one spread.Only the user-agent string.The browser binary to download for that device.4.You want to test date formatting for a German user (dates like 14.05.2026). Where should you set locale: 'de-DE'?In the test using page.setLocale('de-DE').In playwright.config.ts use block, or via test.use({ locale: 'de-DE' }) in a test file.Set the LANG=de_DE environment variable before running tests.In the test using browser.setLocale('de-DE').5.How do you simulate a dropped network connection mid-test to verify an error banner appears?Call page.route('**', route => route.abort()) to abort all requests.Call context.setOffline(true) to simulate a dropped connection.Use process.env.OFFLINE = 'true' before the test action.Use page.setNetworkState('offline') on the page object.6.You want to override the viewport to 768×1024 for a single describe block without affecting the rest of the file. What's the right approach?Call page.setViewportSize({ width: 768, height: 1024 }) inside beforeEach within the describe.Use test.use({ viewport: { width: 768, height: 1024 } }) inside the describe block.Create a new playwright.config.ts file for the describe block.Use test.describe.configure({ viewport: { width: 768, height: 1024 } }).7.How do you test how your app looks and behaves in dark mode using prefers-color-scheme?Click the dark mode toggle button in the app's UI.Set colorScheme: 'dark' in test.use() or call page.emulateMedia({ colorScheme: 'dark' }).Add @media (prefers-color-scheme: dark) as a test tag.Change the OS system preference to dark mode before running tests.8.How do you fake the user's GPS position to test location-based features like a store finder?Mock the navigator.geolocation API using page.evaluate().Set geolocation: { latitude, longitude } in test.use() and grant the 'geolocation' permission.Use a VPN to route test traffic through the target location's IP.Set GPS_LAT and GPS_LON environment variables before running tests.Submit answersarrow-left PreviousDockerBrowsersNext arrow-right