the Chromium logo

The Chromium Projects

Testing System Web Apps (SWAs)

This document outlines techniques for automating CrOS system applications (System Web Apps) such as the Files app, Media App, and Settings.

Prerequisites

Ensure you have completed the setup steps in the main Web Testing on CrOS guide.

Additionally, testing System Web Apps requires the --enable-devtools-pwa-handler flag to be enabled and must be added to the /etc/chrome_dev.conf file on the CrOS device.

Stability Warning: While Puppeteer and Selenium allow you to interact with system-level apps, these tests rely on internal DOM structures (often specific Shadow DOM hierarchies). Unlike public web APIs, ChromeOS system UI can change frequently, which may break your tests. Selectors should be considered brittle and may require regular maintenance.

Finding App Targets

System apps do not appear as standard browser tabs. You must locate the correct "Target" (window or background page) to attach your testing session.

Key Automation Techniques

Example: Interacting with the Files App

This test simulates a full user workflow: downloading a file, opening the Files app, finding the downloaded file, opening it in the Media App, verifying its content, and then deleting it.

Puppeteer Example

The test-file-download.js script uses Puppeteer and the Chrome DevTools Protocol (CDP) to automate the Files app and Media app.

You can view the full script content here: test-file-download.js.

To run this test:

(host)

$ node test-file-download.js ${PORT}

Selenium Example

The test-file-download.py script replicates the same file download and verification workflow using Selenium WebDriver.

You can view the full script content here: test-file-download.py.

To run this test:

(host)

$ python test-file-download.py --driver-path ./chromedriver --port ${PORT}

Playwright Example

The test-file-download.ts script uses Playwright to automate the Files app and Media app, verifying a file download and its content.

You can view the full script content here: test-file-download.ts.

To run this test:

(host)

$ npx ts-node test-file-download.ts ${PORT}