I want to be able to pass arguments to google chrome when running selenium. How can I do that? When I run selenium I use the Java command Java -jar selenium.jar
How
You can send them in your method for launching the driver. e.g.
public static WebDriver chromeBrowser() throws Throwable {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver-location\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox");
WebDriver browser = new ChromeDriver(options);
browser.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
return browser;
}
In nightwatch you should include chromeOptions
with no-sandbox
args into desiredCapabilities
as below :-
"desiredCapabilities" : {
"browserName" : "chrome",
"javascriptEnabled" : true,
"acceptSslCerts" : true,
"chromeOptions" : {
"args" : ["--no-sandbox"]
}
}