Testing a Chrome Extension
Learn how to test your Chrome Extension using Rainforest QA
Overview
In this article we will explain how to download Chrome extensions for use during a test, either by accessing a Chrome profile with preloaded extensions, downloading via the Chrome store, using a "Download" action, or by using code-based actions.
When creating tests that require a Chrome extension, we recommend creating the initial download steps as a reusable snippet. This way no matter what functionally you’re testing, you can insert the snippet and not have to rewrite the steps each time.
Note
Depending on security measures, you may need to create steps to verify your identity to gain access to the Google account. We offer multiple options for 2 factor authentication from within the virtual machine including email and SMS.
Using a Chrome Profile
The preferred method for downloading and testing Chrome extensions is by creating a Google account with the downloaded extensions already installed. You’ll then create test steps to login and sync within Rainforest QA.
Before entering Rainforest QA:
Sync must be turned on in the Google account settings before signing in from within the Rainforest QA virtual machine.
- Go to the Google Account sign in page
- Click ”Create account”
- Enter your name
- In the ‘Username’ field, enter a username
- Enter and confirm your password
- Click ”Next”
- Optional: Add and verify a phone number for your account
- Click ”Next”
Once you have created an account and signed in, turn on sync , and download your extension. This will link it to the newly created account and allow for it to download upon signing in on our virtual machines.
After your Google account is created, within the Rainforest QA visual editor, create test steps based on the following:
- Click the Google account sign in button on the top right of the page.
- Click “Turn on Sync”.
- Enter login credentials.
- Wait for extension(s) to finish downloading.
- Use click actions to approve extension prompts.
- Begin writing additional test steps.
Downloading via the Chrome Store
You can also download your Chrome extension via the Chrome store. Please be aware that using this method may result in flaky tests if Google updates any UI elements utilized in your test. This method will require having a premade Google account and signing in.
- Click the Google account sign in button on the top right of the page.
- Click “Add Account”.
- Click “Sign in”.
- Enter login credentials.
- Navigate to https://chrome.google.com/webstore/category/extensions
- Fill your extension name in the search box.
- Click your extension name.
- Click “Add to Chrome”.
- If applicable, confirm information and click “Add extension”.
- Use click actions to approve any prompts and finish downloading.
Using a Download action
Add a download action type and upload the file directly to the test steps to use it within the virtual machine. Learn more here.
-
Add a download action
-
Search for a file in your file explorer or drag and drop a file into the action.
- Select the expected behavior for your download action. You can set the action to:
- Open the downloaded action
- Open the finder window of the downloads folder so you can select the downloaded file.
- Download the file and do nothing else (i.e. download it in the background)
- Either preview your download action or run the test to execute the download action.
Downloading via a code-based action
You can also download your Chrome extension Using Code-based Actions. This method doesn't use the UI so it eliminates potential flakiness caused by UI changes. It also does not test the process a user would follow to download the extension, which may be important to you.
- Add a comment action step.
- Enter the command in the comment as follows:
rf_vm_command: install_chrome_extension url="…" headers="{'Accept': '...', 'Authorization': '...'}"
- This action downloads a zipped Chrome extension from a given URL (with optional headers).
- Note: This step will restart Chrome, which might affect the state of your existing tabs.
If you have any questions, reach out to us at [email protected].
Updated about 2 months ago