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.

To create a Google account:

  1. Go to the Google Account sign in page
  2. Click ”Create account”
  3. Enter your name
  4. In the ‘Username’ field, enter a username
  5. Enter and confirm your password
  6. Click ”Next”
    • Optional: Add and verify a phone number for your account
  7. 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:

  1. Click the Google account sign in button on the top right of the page.
  2. Click “Turn on Sync”.
  3. Enter login credentials.
  4. Wait for extension(s) to finish downloading.
  5. Use click actions to approve extension prompts.
  6. 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.

  1. Click the Google account sign in button on the top right of the page.
  2. Click “Add Account”.
  3. Click “Sign in”.
  4. Enter login credentials.
  5. Navigate to https://chrome.google.com/webstore/category/extensions
  6. Fill your extension name in the search box.
  7. Click your extension name.
  8. Click “Add to Chrome”.
  9. If applicable, confirm information and click “Add extension”.
  10. 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.

  1. Add a download action

    image.png

    Download action


  2. Search for a file in your file explorer or drag and drop a file into the action.

image.png
  1. Select the expected behavior for your download action. You can set the action to:
    1. Open the downloaded action
    2. Open the finder window of the downloads folder so you can select the downloaded file.
    3. Download the file and do nothing else (i.e. download it in the background)
  2. 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.

  1. Add a comment action step.
  2. Enter the command in the comment as follows: rf_vm_command: install_chrome_extension url="…" headers="{'Accept': '...', 'Authorization': '...'}"
    1. This action downloads a zipped Chrome extension from a given URL (with optional headers).
    2. 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].