Reputation: 83
I'm trying to launch my electron executable using selenium and java in a windows environment but I get a timeout error.
The code that I'm using is something like this:
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\myUser\\MyApp\\MyApp.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
WebDriver driver = new ChromeDriver(capabilities);
When previous code is executed, my application is launched but I can't continue with my test because I get this error from selenium:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.33.506120,platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.21 seconds
......
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
I have tried with different versions of chromedriver and selenium but It doesn't work. Does anyone know what could be the problem?
Note: The error is thrown when this line is executed within HttpCommandExecutor class:
ProtocolHandshake.Result result = handshake.createSession(client, command);
Upvotes: 1
Views: 1566
Reputation: 1184
You need to define chromeDriver args for your application path. I'm sharing my code with you. Hope to help.
ChromeOptions options = new ChromeOptions();
options.setBinary(binaryPath);
options.addArguments("--app=" + argPath);
options.setCapability("chromeOptions", options);
driver = new ChromeDriver(options);
Upvotes: 2