How to use chrome extension when opening chrome browser on a node.

1,359 views
Skip to first unread message

Newbee

unread,
Jun 12, 2012, 4:20:56 PM6/12/12
to seleniu...@googlegroups.com
This my set up: 

I am running Selenium 2 grid, from my hub i am starting a chrome driver and am trying to pass the chrome extension i want to open the browser with on the node using the following code: 
             object[] _chromecap = { "--start-maximized", @"--load-extension= WebCapture.crx" }; 
                    _capabilities = DesiredCapabilities.Chrome();
                    _capabilities.SetCapability("chrome.binary", @"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe");
                    _capabilities.SetCapability("chrome.extensions", _chromeext.ToList());


But when i run this i get an error on the node "Manifest file not found". 

I then try the following: 

                    object[] _chromecap = { "--start-maximized"}; 
                    object [] _chromeext = { @"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\19.0.1084.56\Extensions\WebCapture.crx"};
                    _capabilities = DesiredCapabilities.Chrome();
                    _capabilities.SetCapability("chrome.binary", @"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe");
                    _capabilities.SetCapability("chrome.extensions", _chromeext.ToList());
                    _capabilities.SetCapability("chrome.switches", _chromecap.ToList());

but now i get an error that "Failed to base64 decode extension". I am at the end of my wits rt now.. any assistance is welcome.. 

Thanks 

Jim Evans

unread,
Jun 12, 2012, 5:21:09 PM6/12/12
to seleniu...@googlegroups.com
What happens when you use the ChromeOptions class? For example:

ChromeOptions options = new ChromeOptions();
options.AddExtension(@"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\19.0.1084.56\Extensions\WebCapture.crx");
options.AddArgument("--start-maximized");
options.BinaryLocation = @"C:\Users\Administrator\AppData\Local\Google\Chrome\Application\chrome.exe";

// For a local ChromeDriver, use this:
IWebDriver driver = new ChromeDriver(options);

// For using RemoteWebDriver, use (changing "http://your/remote/server:port/wd/hub" to point to your remote server):
// DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
// capabilities.SetCapability(ChromeOptions.Capability, options);
// RemoteWebDriver driver = new RemoteWebDriver(new Uri("http://your/remote/server:port/wd/hub"), capabilities);

Newbee

unread,
Jun 12, 2012, 5:34:07 PM6/12/12
to seleniu...@googlegroups.com
Jim that worked!! ... but it looks like the extension is being sent from the hub to the node through the network. Is this the most efficient way to proceed? 

Can i not just open the node chrome browser with the extension installed? May be the following steps might make it more clear. 

1. Manually open chrome browser, drag and drop the extension in chrome. 
2. It asks if i want to Install it, i go ahead and install this. 
3. Next time I go to the specific URL manually that needs this extension to run, it runs fine without any pop-ups. 
4. Start my code to run from the hub, (without the path to use the extension). It asks me to install the extension every single time. 

I understand that it is opening a completely new copy of chrome every single time, but is there no other way this can be handeled on the node instead of sending the extension over the hub? just wondering.... 

But thanks for the code above ... its working for my setup as is. 

Jim Evans

unread,
Jun 12, 2012, 5:55:33 PM6/12/12
to seleniu...@googlegroups.com
Efficient or not, it's your only option at present. The Chrome driver doesn't allow you to specify a custom profile when you launch Chrome[1]. Rather, it creates an empty profile for each instance it's launching. That means that the extension has to be installed in the profile before Chrome is launched, and since hub and node are (and ought to be) decoupled from one another and have no knowledge of each others' file systems, the only way to get that extension across to the node is to send it across the wire.

--Jim

[1] Documented in the project wiki at http://code.google.com/p/wiki/ChromeDriver
Message has been deleted
Message has been deleted

Newbee

unread,
Jun 12, 2012, 7:46:56 PM6/12/12
to seleniu...@googlegroups.com
Hello Jim.. i have created a new thread for this question since i think the primary question that i had here was answered. If you can I would appreciate your input on this thread: 

Babette Wagner

unread,
Dec 20, 2013, 3:33:40 AM12/20/13
to seleniu...@googlegroups.com
I have gone the same way, but in the path mentioned for the extension there is no .crx, just a .dll

My Steps:
- downloaded the desired .crx
- dropped it on plugins page and answerd 'yes' to install, plugin is now available in running version of chrome

chrome://plugins/ detail view shows me "C:/Users/bw/AppData/Local/Google/Chrome/User Data/Default/Extensions/jpjpnpmbddbjkfaccnmhnkdgjideieim/1.0.9738_0/WINNT_x86-msvc/npGwtDevPlugin.dll"

My Code:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addExtensions(new File(
"C:/Users/bw/AppData/Local/Google/Chrome/User Data/Default/Extensions/jpjpnpmbddbjkfaccnmhnkdgjideieim/1.0.9738_0/WINNT_x86-msvc/gwt-dev-plugin.crx"));
chromeOptions.setBinary(new File("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"));

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
webDriver = new RemoteWebDriver(service.getUrl(), capabilities);

If I run the code I get: 
org.openqa.selenium.WebDriverException: unknown error: cannot process extension #1
from unknown error: cannot unzip

If I place the .crx in the same directory and use it in my code I get the following error message

Reply all
Reply to author
Forward
0 new messages