# Testing Chrome Extensions

An average Chrome Extension is HTML5 application, therefore we can test it with Puppetry. The only difference here is in way we obtain the page context. The following walkthrough explains how it can be done:

1\) Open Chrome browser.

2\) Navigate to `chrome://extensions`

3\) Turn on the **Developer mode** switcher.

![Loading the Chrome extension](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtyPMrE3gry2wECcugk%2F-LtyfDspPJ00oc68b9-8%2Fchrome1.png?alt=media\&token=621ae030-b3a9-4a7f-ac32-79aad5939242)

4\) Load the unpacked version of your extension. You can create a demo one with [extensionizr.com](https://extensionizr.com/) service.

![Saving Chrome extension ID](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtyPMrE3gry2wECcugk%2F-LtyfHvtmHBGhELBTGN8%2Fchrome2.png?alt=media\&token=45f08950-ed97-4ba1-a5d5-59e9597c8686)

5\) Write down the extension ID (e.g. `eclajhagmjdnniapeipnfejgmplgehme`) from appeared extension card.&#x20;

6\) Launch Puppetry and create an empty test case

7\) Check the extension `manifest.json` file for `default_popup` value (e.g. `src/page_action/page_action.html`)

8\) Add command `page.goto` with URL like **chrome-extension://EXTENSION\_ID/EXTENSION\_RELATIVE\_URL** (e.g. `chrome-extension://eclajhagmjdnniapeipnfejgmplgehme/src/page_action/page_action.html`)

![Navigating to the Chrome extension main page](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtyPMrE3gry2wECcugk%2F-LtygTdg4Oo8N6qBpw9c%2Fchrome3.png?alt=media\&token=3d774c68-a897-436a-9349-81fa7286f450)

9\) Add command `page.screenshot` to take a screenshot when the extension HTML is loaded

10\) Open **Run Tests** dialog (press **F6** or **Run** in the main menu)

11\) Switch to **Browser options** and set the Chrome extension folder location (with **Browse...** button)

![Feeding Chrome extension sources to Puppetry](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtyPMrE3gry2wECcugk%2F-Ltyh1TJe1EsPh9jYEpg%2Fchrome4.png?alt=media\&token=2500deaf-93c8-4e0d-ab72-82420a275da2)

12\) Click on **Run** button

13\) Observe the report

![Chrome extension test results](https://3461068122-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdyKJ-zzeS2hB7DF04J%2F-LtyPMrE3gry2wECcugk%2F-LtyhBLeAwDyfQtpZn_v%2Fchrome5.png?alt=media\&token=cbd8a725-eeb6-49a6-bd6b-7c8c897f05ab)

\
So we have got the screenshot with Chrome extension page view. Thus we can develop a real test case with commands and assertions pointed at the extension page context.
