I want to write an acceptance test for my browser extension. I've tried to initiate an extension via selenium but I can't seem to access a content of popup. Can someone suggest how can I do it with selenium or any other way to write UI/acceptance tests for browser extensions? Thanks.
2 Answers
How can I access browser extension's popup using selenium?
It's not possible. Selenium supports interaction with web view only.
What you can do with Selenium
and extension
for sure is automatic installation: https://stackoverflow.com/a/16512012/2517622
You may try to use desktop automation tools (e.g. White on Windows
platform) for clicking on extension popup but it's not that easy and it's not platform independent as Selenium.
-
Even tho I use Desktop automation, how can I navigate inside the popup then? – Andrii Zarubin Dec 22 '15 at 16:35
-
It depends on the tool which you are going to choose. – drets Dec 22 '15 at 17:15
-
I am ok to use any tool that can do the job. It sounds quite difficult to do things with desktop automation tools in fact. My guess is that there has to be something (like Selenium) that can communicate with browser through its API. – Andrii Zarubin Dec 23 '15 at 12:39
-
Blind guess how to control your extension: write your options page for testing (https://developer.chrome.com/extensions/options) and control extension using that page and Selenium. – drets Dec 23 '15 at 13:29
-
Well, this is how we do it now. But it seems hackish way. I was hoping to find something more "legal" – Andrii Zarubin Dec 24 '15 at 07:30
-
I don't think that you have a choice except using desktop automation tools like White. – drets Dec 24 '15 at 10:48
Here is the workaround we came up. Unless someone posts here the "right" solution I will consider this as the best approach.
So eventually, our extension is an iframe which just loads a page content from our website + does some other neat stuff. We simply open that url in a new tab and do regular selenium tests.
Side not: we have considered to write a little javascript wrapper to be able to access ext via main window through javascript. E.g. there is some js in ext that listens to main window's events and perform certain actions. Tho, it is too much efforts and doesn't really sound like a proper acceptance test so we discarded this approach.

- 2,165
- 1
- 18
- 31