Start Electron application with Selenium WebDriver using command line arguments


#1

I have an Electron application (chat.exe) and using the following code snippet I can start it with Chromedriver(Java):

ChromeOptions options = new ChromeOptions();
options.setBinary(System.getenv("CHAT")); // CHAT = path to C:\Chat.exe
driver = new ChromeDriver(options);

My question is: how can I start it with command line arguments?

e.g. chat.exe -- --electronPort 5000 --webpackPort 3000 --accessToken 123456789

I tried the following way but didn’t worked:

ChromeOptions options = new ChromeOptions();
options.setBinary(System.getenv("CHAT"));
options.addArguments("-- --electronPort 5000 --webpackPort 3000 --accessToken 123456789");
driver = new ChromeDriver(options);

The following error is displayed:

org.openqa.selenium.WebDriverException: chrome not reachable

The same happens for:

ChromeOptions options = new ChromeOptions();
options.setBinary(System.getenv("CHAT"));
options.addArguments("electronPort=5000", "webpackPort=3000", "accessToken=123456789");
driver = new ChromeDriver(options);