How to add Chrome Extension using Desired Capabilities
There are two ways a chrome extension can be automated in Testsigma.
1. Hybrid Execution - Chrome browser on your machine
2. Cloud Execution - Chrome browser on Testsigma Lab/ SauceLabs/ Browserstack
In this article, we will guide you on how to run chrome extension tests for Hybrid and Testsigma Labs.
Set up and Running Automated Tests for Chrome Extension
A chrome extension is a simple program that extends the functionality of your chrome browser.
Chrome extensions can be added to the chrome browser via the Chrome Web Store from the below link.
Or search for <Name Of Extension > Chrome Extension on your favorite search engine. This will provide you the Web Store link.
For example :
Step 1: Create a CRX file
Navigate to https://robwu.nl/crxviewer/
Click on Open in this viewer
Click on CRX
This will download the CRX file to your desktop which is essential for automating the chrome extension.
observe the above image. When you search for \.html?$ , You will find a few HTML files like
In most cases, popup.html is what you would be automating.
we need to access this file first on your chrome browser.
For this, we first navigate to chrome://extensions/ on your chrome browser.
Now move to the plugin that you need to automate and click the Details button as shown on the screen.
Copy the unique text available in the ID field.
In this case, it is epmomlhdjfgdobefcpocockpjihaabdp
As an example - use this link with proper ID and HTML to open the view for your chrome extension
This should ideally navigate you to the web view of your chrome extension which you are looking forward to automating.
This same step needs to be executed using Testsigma. But first, we will provide Testsigma the path for your CRX file.
In Hybrid Mode - Local Test Execution - on your chrome browser
Ensure the Agent is up.
2. Copy the CRX file to your Testsigma Agent Folder
3. Write a simple custom function to navigate to chrome extension and print the Capabilities
4. Specify the Extensions path in the Desired Capabilities
Place the CRX file inside the Testsigma Agent folder
Add an Execution Configuration in Testsigma and add the following Desired Capability:
To add more than one extension, give the value in the format:
That's all we need to do in order to add an extension to an Automation Session in Testsigma using Desired Capabilities.
Once the execution starts, it will automatically take the file and install it to the Browser. To confirm whether the given extension is added or not, you can check the extension icon in the top right corner of the browser as shown in the below screenshot.
In Hybrid Mode - Cloud Test Execution - on Testsigma TestLab chrome browser
In this case, we have a few additional steps.
Since we do not have access to the TestLab device, we will have to write a simple custom function that will copy the CRX file from a URL to /opt/agent folder inside the test lab machine.
A screenshot of the custom function is shown here.
As an example, we have stored the CRX file in AWS S3 instance.
Don't forget to add the imports.
This custom function needs to add to a separate test case.
Run this test case as a prerequisite inside a test suite where the main test case navigates to the chrome extension.
The test suite thus created needs to be added to a test plan which will eventually be run.
Repeat the Desired capabilities step and then execute the test plan.
Welcome to the era of #SmartTestAutomation!