Testing with Chrome Extensions

1,328 views
Skip to first unread message

Ryan

unread,
Sep 27, 2014, 3:28:50 AM9/27/14
to nightw...@googlegroups.com
Hi everyone,

Has anyone figured out how to enable a Chrome extension for use in Nightwatch.js? 

My goal is to have this extension enabled while running tests:
No special interaction with the extension is needed.

There are great guides for doing this in Selenium and Java (https://sites.google.com/a/chromium.org/chromedriver/capabilities)
Does Nightwatch.js support this?

Thanks!

James Eisenhauer

unread,
Apr 24, 2015, 5:27:15 PM4/24/15
to nightw...@googlegroups.com
I need to do this now as well.  Is it possible?

jim

Daniel Rinehart

unread,
Apr 25, 2015, 11:01:44 AM4/25/15
to nightw...@googlegroups.com
Based on the page that you linked to, I would guess, you just need to add additional flags to the chromeOptions object in your nightwatch configuration. For example this uses the args block to launch full screen. Using the "extensions" key might be worth a try.

"chrome": {
  "desiredCapabilities": {
    "browserName": "chrome",
    "javascriptEnabled": true,
    "acceptSslCerts": true,
    "chromeOptions": {
      "args": ["start-fullscreen"]
    }
  }
},

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/62a3344e-5c57-4237-bf55-f8857502d58c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Eisenhauer_work

unread,
Apr 25, 2015, 1:35:05 PM4/25/15
to nightw...@googlegroups.com
thanks

I am able to get this to work, but I have to use the full path, which I need to make dynamic.  I have been trying to put this into the nightwatch.conf.js file but everything I do gives me unable to parse chromeOptions.

example one method i tried 
settings.test_settings.default.desiredCapabilities.chromeOptions = "{ args: [ '--load-extension=/Users/jeisenha/Documents/workspace/demowebsite/utils/chrome-ext' ] }";



 "chromeOptions": {
                   "args": ["--load-extension=/Users/jeisenha/Documents/workspace/demowebsite/utils/chrome-ext"]
                }
            }

On Saturday, September 27, 2014 at 12:28:50 AM UTC-7, Ryan wrote:

Daniel Rinehart

unread,
Apr 25, 2015, 1:41:07 PM4/25/15
to nightw...@googlegroups.com
Try removing the leading "--", when using chromeOptions they are not used.

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.

James Eisenhauer_work

unread,
Apr 25, 2015, 2:01:27 PM4/25/15
to nightw...@googlegroups.com
Giving it a hard coded URL to the extensions worked for me with the dash.

Dynamic URL I figured out.  It has to be an object that you pass in the nightwatch.json.js file.

var ext_var = "args": ["--load-extension=.full/path/to/chrome_ext"]}';
settings.test_settings.default.desiredCapabilities.chromeOptions = JSON.parse(ext_var);

Rita

unread,
Jun 21, 2016, 7:38:31 AM6/21/16
to NightwatchJs
Hi guys,

Did it work?
Did u manage to add chrome extensions to your nightwatch?
Thanks

Jens Gellynck

unread,
Oct 22, 2016, 12:40:56 PM10/22/16
to NightwatchJs
Hi Rita,

I managed to get an extension to work, this is the config I used: (same as James wrote above)

"desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled" : true,
        "acceptSslCerts" : true,
         "chromeOptions": {
                   "args": ["--load-extension=/home/jens/.config/google-chrome/Default/Extensions/laookkfknpbbblfpciffpaejjkokdgca/0.91.5_0/"]
        }
      }

This is on an Ubuntu machine so the path may be different on your machine depending on your operating system.
Also note I used the path of my actual chrome browser, but you can also download the extension-package and use that path.

Then I accessed my extension using the url: chrome-extension://laookkfknpbbblfpciffpaejjkokdgca/dashboard.html

I hope this may help you.

Op dinsdag 21 juni 2016 13:38:31 UTC+2 schreef Rita:

Rita

unread,
Oct 26, 2016, 11:17:14 AM10/26/16
to NightwatchJs
Hi Jens,

Thanks for your reply. 
I will try.
Reply all
Reply to author
Forward
0 new messages