Reloading a Chrome Extension using Selenium WebDriver

Handling multi-level shadow roots in Selenium WebDriver

Zhimin Zhan
4 min readJan 31, 2022

--

A repost of my daughter’s article with permission. I added it here for the convenience of my blog subscribers. Reloading a Chrome extension involves multi-level shadow roots. This article shows how.

This article is included in my “How to in Selenium WebDriver” series.

Some automated tests require browser extensions to complete an action. For instance, testing whether a login ‘Remember Me’ works via a cookie.

However, not all browser extensions work immediately, some may need to be refreshed first.

This tutorial will show you a script that will refresh a Chrome extension before a test begins.

The Scenario

We want to log in to a sample site with a cookie. To store this cookie, I will use the Chrome ModHeader extension in this tutorial. First, start Chrome with the extension (I used this tutorial for how to drive Chrome with Extensions using Selenium WebDriver).

Following this, just running the basic test will give you this window:

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.