Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Selenium Web Driver Set Chrome Options
//import the selenium web driver
var webdriver = require('selenium-webdriver');
var chromeCapabilities = webdriver.Capabilities.chrome();
//setting chrome options to start the browser fully maximized
var chromeOptions = {
'args': ['--test-type', '--start-maximized']
};
chromeCapabilities.set('chromeOptions', chromeOptions);
var driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
@jbdoster
Copy link

jbdoster commented Sep 4, 2019

Thank you!!!

@codingyourlife
Copy link

Addition to my comment. I've now upgraded to node 12 since it is now LTS and ran into this issue:
ERR_MODULE_NOT_FOUND selenium-webdriver/chrome

Since import of selenium-webdriver/chrome does no longer work
import chrome from "selenium-webdriver/chrome"; //broken

Here is my workaround:

import require from "requirejs";
const chrome = require("selenium-webdriver/chrome"); //works

This again took me quite a while to find out so I hope this helps!

@harrisonhenri
Copy link

Is it possible to disable w3c using this config?

@rachidelaid
Copy link

dose anyone knows how to do the same with firefox. (open firefox with a specific profile path)

@qquach
Copy link

qquach commented Oct 14, 2020

some good source: https://chromedriver.chromium.org/capabilities
and https://peter.sh/experiments/chromium-command-line-switches/

The new syntax for nodejs (NOTE: the key value)
chromeCapabilities.set("goog:chromeOptions", options);

@ramrami
Copy link

ramrami commented Oct 17, 2020

Thank you

@gulraiz-malhi
Copy link

Thanks @qquach

@jcharnley
Copy link

@purejgleason
Copy link

You rock!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment