How to launch Chrome w/ new command line options using ChromeDriver

5,580 views
Skip to first unread message

Davis W. Frank

unread,
May 20, 2011, 2:50:07 PM5/20/11
to Selenium Developers
Now that we're using ChromeDriver to drive Chrome w/ Webdriver/
Selenium, how do we launch the browser with specific command line
options?

We happen to be using Capybara in Selenium mode, and thus the selenium-
webdriver Ruby Gem. And we need to launch Chrome w/ '--disable-web-
security'.

It appears that the browser gets launched by ChromeDriver, but we've
lost the ability to pass the command line switches.

thx,
--dwf

Simon Stewart

unread,
May 24, 2011, 9:34:58 AM5/24/11
to selenium-...@googlegroups.com
Hi,

The next release of Selenium features a rewritten chrome driver that
does away with the need for the "disable-web-security" flag. It should
have been out last Friday, so I expect it to be released very, very,
very soon.

Simon

> --
> You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
> To post to this group, send email to selenium-...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-develo...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/selenium-developers?hl=en.
>
>

François Reynaud

unread,
May 24, 2011, 11:48:51 AM5/24/11
to selenium-...@googlegroups.com
It would be great to be able to pass any command line parameter to chrome, not only chrome flag but also system param. I'm thinking about the --display on linux to isolate the browsers.

Jari Bakken

unread,
May 24, 2011, 5:27:32 PM5/24/11
to selenium-...@googlegroups.com
2011/5/24 François Reynaud <francois...@gmail.com>:

> It would be great to be able to pass any command line parameter to chrome,
> not only chrome flag but also system param. I'm thinking about the --display
> on linux to isolate the browsers.
>

The next release of the chromedriver binary will let you pass custom
switches through DesiredCapabilities:

http://src.chromium.org/viewvc/chrome?view=rev&revision=85289

I don't think Chrome supports a --display argument though.

François Reynaud

unread,
May 25, 2011, 7:01:43 AM5/25/11
to selenium-...@googlegroups.com
I don't need chrome to use the param, but the OS

linux1:~$ google-chrome --display :1
works for me.It starts chrome in the display specified. If I can have that param passed when chrome is launched, then I can do cool things with grid :) 

thanks,
françois



--

Davis Frank

unread,
May 24, 2011, 11:54:21 AM5/24/11
to selenium-...@googlegroups.com
In the meantime we've managed to, via a shell script, insert ourselves between what chromedriver launches and are attempting to add command line flags. It turns out we need to not only disable web security, but launch w/ additional profile options.

We'll blog/post about our solutions once we've got something working.

This probably should be exposed better via chromedriver - that command line switches are passed on to Chrome. Then other bindings - we're using Ruby - can pass the options through.

--dwf



2011/5/24 François Reynaud <francois...@gmail.com>

Jari Bakken

unread,
May 25, 2011, 1:56:41 PM5/25/11
to selenium-...@googlegroups.com
On Tue, May 24, 2011 at 5:54 PM, Davis Frank <dwf...@pivotallabs.com> wrote:
> In the meantime we've managed to, via a shell script, insert ourselves
> between what chromedriver launches and are attempting to add command line
> flags. It turns out we need to not only disable web security, but launch w/
> additional profile options.
> We'll blog/post about our solutions once we've got something working.
> This probably should be exposed better via chromedriver - that command line
> switches are passed on to Chrome. Then other bindings - we're using Ruby -
> can pass the options through.

As mentioned, this will be supported in the next released build of the
Chrome server. I've also added TODO in the Ruby bindings about
exposing it to the user:

http://code.google.com/p/selenium/source/browse/trunk/rb/lib/selenium/webdriver/chrome/bridge.rb#18

Yuriy Gerasimov

unread,
May 26, 2011, 1:38:09 AM5/26/11
to Selenium Developers
Hi Jari,

It would be very very useful to pass any custom parameters to Chrome
when it starts. Please keep us updated when this functionality is
ready for testing.

My personal aim is to change User-Agent string using --user-
agent="User Agent String" parameter.

Thank you tons.

Best regards,
Yuriy

On May 24, 5:27 pm, Jari Bakken <jari.bak...@gmail.com> wrote:
> 2011/5/24 François Reynaud <francois.reyn...@gmail.com>:

Artem Kozlov

unread,
Jun 14, 2011, 7:56:11 AM6/14/11
to Selenium Developers
Is this already possible with Java bindings?

On May 25, 8:56 pm, Jari Bakken <jari.bak...@gmail.com> wrote:
> On Tue, May 24, 2011 at 5:54 PM, Davis Frank <dwfr...@pivotallabs.com> wrote:
> > In the meantime we've managed to, via a shell script, insert ourselves
> > between whatchromedriverlaunches and are attempting to addcommandline
> > flags. It turns out we need to not only disable web security, butlaunchw/
> > additional profileoptions.
> > We'll blog/post about our solutions once we've got something working.
> > This probably should be exposed better viachromedriver- thatcommandline
> > switches are passed on toChrome. Then other bindings - we'reusingRuby -
> > can pass theoptionsthrough.
>
> As mentioned, this will be supported in the next released build of theChromeserver. I've also added TODO in the Ruby bindings about
> exposing it to the user:
>
>  http://code.google.com/p/selenium/source/browse/trunk/rb/lib/selenium...

Jari Bakken

unread,
Jun 14, 2011, 10:01:03 AM6/14/11
to selenium-...@googlegroups.com
On Tue, Jun 14, 2011 at 1:56 PM, Artem Kozlov
<master...@googlemail.com> wrote:
> Is this already possible with Java bindings?
>

Assuming you've downloaded the latest chromedriver binary, I believe
you can make it work by doing e.g.:

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.switches",
Arrays.asList("--disable-translate", "--foo-bar=1"));
WebDriver driver = new ChromeDriver(caps);

Jari

Artem Kozlov

unread,
Jun 14, 2011, 10:10:14 AM6/14/11
to Selenium Developers
Thanks, it work!

On Jun 14, 5:01 pm, Jari Bakken <jari.bak...@gmail.com> wrote:
> On Tue, Jun 14, 2011 at 1:56 PM, Artem Kozlov
>
> <masterzim....@googlemail.com> wrote:
> > Is this already possible with Java bindings?
>
> Assuming you've downloaded the latestchromedriverbinary, I believe
Reply all
Reply to author
Forward
0 new messages