How to Automatically Install and Enable a Chrome Extension

calendarAugust 6, 2021 in Chrome , Edge , HttpWatch

The HttpWatch installer adds the HttpWatch extension to Chrome but the user needs to manually approve it before its first use:

Our larger customers typically install HttpWatch through automated scripts using command line flags to silently run the installer. Unfortunately, the manual step shown above is still required on each PC before the user can access HttpWatch.

There is a way to force the installation of HttpWatch or any other Chrome extension using Chrome extension policies. The ExtensionInstallForcelist value specifies which extensions should be automatically installed and enabled from the Chrome Web Store. This value is stored in the registry in the following location for all users:

HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\ExtensionInstallForcelist

or in this location for a single user:

HKEY_CURRENT_USER\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist

Each extension to be installed in this way must have a numbered value. For example, with HttpWatch the entry would be:

[HKEY_LOCAL_MACHINE\Software\Policies\Google\Chrome\ExtensionInstallForcelist] = "1"="dajhhgiioackgdldomhppobgjbinhimh"

In RegEdit it would look like this:

The next time Chrome restarts it will automatically download and enable the extension without requiring any manual intervention. An added advantage of doing this with HttpWatch is that no debugging banner is displayed in Chrome when HttpWatch is recording.

Microsoft Edge has a similar set of policies that can also be used to force the installation of an extension.

HttpWatch 12.1 Supports Microsoft Edge (Chromium)

calendarOctober 23, 2019 in Chrome , Edge , HttpWatch

The latest update to HttpWatch includes experimental support for the beta version of Microsoft Edge (Chromium). Full support, including automation, will be added at a later date when Edge (Chromium) is officially released.

The Microsoft store does not yet support chromium based browser extensions but you can install the HttpWatch extension from the Chrome web store instead. The following steps guide you through adding HttpWatch to Edge Chromium

1. Install HttpWatch 12.1

Download and install the latest version of HttpWatch

2. Install Edge (Chromium Beta)

You can download the Edge Insider Beta Channel from https://www.microsoftedgeinsider.com/

3. Allow Edge to Install HttpWatch from The Google Web Store

Open Edge (Chromium) Beta and go to …->Extensions or enter ‘edge://extensions/’ in the location bar. Then select ‘Allow extensions from other stores’ and click Allow:

Allow Edge to install extension from Chrome Web Store

4. Install the HttpWatch extension from the Chrome Web Store

In Edge open the HttpWatch extension page at:

https://chrome.google.com/webstore/detail/httpwatch/dajhhgiioackgdldomhppobgjbinhimh

Then click ‘Add To Chrome’ which will add the extension to Edge:

Once the extension has been added you can either access HttpWatch from the toolbar icon or by right clicking on the web page and selecting ‘Open HttpWatch’.

How to use Selenium automation with HttpWatch and Chrome

calendarJanuary 11, 2018 in Automation , C# , Chrome , HttpWatch

The HttpWatch automation interface provides programmatic control of HttpWatch in both IE and Chrome browsers. It can be used to develop tests in almost any programming language (e.g. C#, JavaScript, Ruby, etc) that capture low level network timings, errors and other statistics generated when a web page is accessed.

However this interface only provides a basic GotoURL method to navigate between pages. If your testing requires more interaction, for example submitting forms or clicking on buttons, we recommend using the Selenium automation framework. The latest HttpWatch update (version 11.1.19) includes several Selenium related improvements to make the integration even easier:

In Visual Studio you no longer the need to separately download and install Selenium. Simply add these two Nuget packages to your project:

Once you’ve done this, Selenium will be automatically downloaded and installed when you build your project. It also makes maintenance easier as Visual Studio will show you when updates to these packages are available.

Starting a session using both HttpWatch and Selenium in Chrome requires just a few simple steps. The first is creating Selenium with the HttpWatch extension installed:

Controller control = new Controller();
 
// Make sure the HttpWatch extension is enabled in the Selenium Chrome session by referencing the CRX file
// e.g. C:\Program Files (x86)\HttpWatch\HttpWatchForChrome.crx
// The HttpWatchCRXFile property returns the installed location of the CRX file
var options = new ChromeOptions();
options.AddExtension(control.Chrome.HttpWatchCRXFile);
 
// Start the Chrome browser session
var driver = new ChromeDriver(options);
 
// Goto blank start page so that HttpWatch recording can be started
driver.Navigate().GoToUrl("about:blank");

The new HttpWatchCRXFile property saves you having to hard code a path to the HttpWatch installation on your PC.

The next step is attaching HttpWatch to the instance of Chrome created by Selenium. This is achieved by setting a unique page title and then calling the AttachByTitle method:

// Set a unique title on the first tab so that HttpWatch can attach to it
var uniqueTitle = Guid.NewGuid().ToString();
driver.ExecuteScript("document.title = '" + uniqueTitle + "'");
 
// Attach HttpWatch to the instance of Chrome created through Selenium
Plugin plugin = control.AttachByTitle(uniqueTitle);

Once everything is setup you can use Selenium methods to interact with controls on the page and HttpWatch methods to control recording and lookup the required network level data or timings:

driver.Navigate().GoToUrl(url);
 
// Start recording now that page containing the form is loaded
plugin.Log.EnableFilter(false);
plugin.Clear();
plugin.Record();
 
// Put 200 in the amount field
driver.FindElement(By.Name("Amount")).Clear();
driver.FindElement(By.Name("Amount")).SendKeys("200");
 
// Click on the submit button
driver.FindElement(By.Name("B2")).Click();
 
Console.WriteLine("\r\nClicked on submit button...");
 
// Use the HttpWatch Wait call to ensure HTTP activity has ceased
control.Wait(plugin, -1);
 
// Stop recording HTTP
plugin.Stop();
 
// Read the updated account balance back from the page
string accountBalance = driver.FindElement(By.Id("balanceSpan")).Text;
 
if (plugin.Log.Pages.Count != 0)
{
    Console.WriteLine("\r\nPage Title: '" + plugin.Log.Pages[0].Title + "'");
    Console.WriteLine("\r\nNew account balance: " + accountBalance );
    Console.WriteLine();
 
    // Display summary statistics for page
    Summary summary = plugin.Log.Pages[0].Entries.Summary;
    Console.WriteLine("Total time to load page (secs):      " + summary.Time);
    Console.WriteLine("Number of bytes received on network: " + summary.BytesReceived);
    Console.WriteLine("HTTP compression saving (bytes):     " + summary.CompressionSavedBytes);
}
 
// Need to use Selenium Quit to correctly shutdown Selenium and browser
driver.Quit();

You can read more about the Selenium and Chrome sample code in the HttpWatch Automation documentation.

Ready to get started? TRY FOR FREE Buy Now