Ask a Question

Testing a chrome extension with TestComplete


Testing a chrome extension with TestComplete



I'm trying to use TestComplete to test a Chrome extension that is currently in development. When I click on the icon it will display a popup like so:



As far as I know there is no way to reliably target and click the icon. Please let me know if there is.

Since the popup is actually another webpage (this is just how chrome extensions work) I tried to work around this by opening it by itself. You can do this by opening a url like chrome-extension://<extention-unique-id>/popup.html


So now I have a web page like this:




But for some reason, I cannot find the 'Take Screenshot' button in TestComplete.

It finds the page but it does not have any children




Here is the HTML for the page:

            button {
                white-space: nowrap;
                outline: none;
    <button id="takeScreenshot">Take Screenshot</button>
        <script src="popup.js"></script>


Does anyone have any ideas/experiance testing chrome extensions? I came up with this method from this selenium post so I know it's possible



Esteemed Contributor

This is one of the few cases where I'd suggest using FindChildByXPath.  My guess is that the button is not recognized by TestComplete's engine as a UI component because it doesn't match some sort of pattern.  So, an XPath search may find the button and allow you to interact with it.

Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available



I tried FindChildByXPath but no luck...

I'm noticed that the SmartBear extension doesn't inject the hidden nodes that it normally does in other pages.

When I right click on the extension while my chrome extension page is open I see:


I think this is a chrome limitation. It doesn't allow us to inject into it's internal pages. 


For security considerations Chrome refuses all extensions to inject code into its internal pages (about:*chrome:*). Because of that, internal pages, like the new tab page, the extension manager, the download manager, the history page and so on, are not accessible to TestComplete.




I may need to switch to selenium for this one... It doesn't have this limitation.

Champion Level 2

@thePantz :



I am afraid that you are referencing help topic that describes exactly the reason of the problem.

One quick idea meanwhile:

-- If TestComplete Object Browser can access internals of the .contentDocument property, you may try to search for and work with web elements via native DOM functions like it is described in the and help topics.


  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
SmartBear Alumni (Retired)

Hi @thePantz,


Because of the Chrome specifics, TestComplete can only get access to the viewport of the browser - the actual pages you visit. That's why currently there is no way to recognize elements in extension popups. As far as I know, the same goes for Selenium - it only allows you to work with the popup if you open it in Chrome as an individual HTML page, but TestComplete has no issues with this scenario as well.


As a workaround, I can suggest using the image-based approach - finding elements by their images. You can also use Optical Character Recognition to obtain elements by their text (please note that it requires a separate license for the TC IQ add-on).


Julia Bernikova
SmartBear Customer Care Manager - TestComplete

@AlexKaras I'm afraid the .contentDocument I get is null in this case. However it is visible if I change my my Web Object Model from a Tree View Model to a DOM Model

SmartBear Alumni (Retired)



The DOM model is a deprecated web testing mode which might cause issues with performance, so
I suggest you stick with the Tree model.


Julia Bernikova
SmartBear Customer Care Manager - TestComplete

@JuliaBernikova As I explained in my original post, TestComplete cannot locate the elements when you open the popup on an indivudual page. I did not have difficulties when using Selenium so I have gone that route. I will not pay for an Image Recognition module when I can get more reliable results from Selenium.

SmartBear Alumni (Retired)



I should have put it differently: by an individual HTML page, I meant opening HTML locally as a file, not via chrome-extension://. It's good to know that Selenium supports this mode though - the next TestComplete version will introduce a cross-platform web testing feature that allows running tests using Selenium Grid. So, our product team will check if we can make TestComplete work with chrome-extension:// pages too.


Julia Bernikova
SmartBear Customer Care Manager - TestComplete
Showing results for 
Search instead for 
Did you mean: