I have created a chrome extension that makes API calls to database and fetches some data relevant to a website that is currently open. For example, if I open target.com and click on extension that it will give you data relevant to target.com.
I am trying to write automated tests for it through selenium web driver which I can run on a regular basis for regression testing. To test the extension, I need to first open the extension (generally we do it by clicking on the extension icon).
I have tried different ways of attempting to click on the extension icon but have not been successful. (For example, using the keyboard shortcut ALT - LEFT_ARROW - SPACE but that does not work through webdriver).
I have also tried this (mentioned here):
options = webdriver.ChromeOptions()
options.add_argument("--app-id = mbopgmdnpcbohhpnfglgohlbhfongabi")
But above code does not help in opening extension.
I would appreciate any thoughts on how can I do this using python in Selenium Webdriver.
You can use this solution, for simulating the click on the extension icon
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.postMessage('clicked_browser_action', '*')");
Selenium supports interaction with web view only - so this is not possible.
I have been searching for solution to this one for some time - and it turned out there is none.
https://code.google.com/p/selenium/issues/detail?id=7805
http://grokbase.com/t/gg/selenium-developer-activity/148xndmkna/issue-7805-in-selenium-clicking-on-chrome-extension-to-open-popup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With