0

I have electron based application need to automate, but start exe need to pass parameter, how to pass parameters when use spectron or selenium to do the automation?

Here is the cmd to start Electron:

Electron.exe --manifest  https://hostname/quantum/configs/openfin/manfest-uat.json

My code

System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\xxx\\xx\\lf2v0\\UAT1\\e2o\\Electron.exe");
options.addArguments("--app=" + "C:\\xx\\xx\\lf2v0\\UAT1\\e2o");
options.addArguments("--manifest=" + "https://xxx/quantum/configs/openfin/manifest-uat.json");
options.setCapability("chromeOptions", options);
ChromeDriver driver = new ChromeDriver(options);
Thread.sleep(5000);
Set<String> windowHandles = driver.getWindowHandles();

here is the error org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist

Ryan M
  • 18,333
  • 31
  • 67
  • 74

1 Answers1

0

You can define your electron app and you can send Argument while you are initializing it like following:

argPath = path of your application executable

binaryPath = path of electron binary

   System.setProperty("webdriver.chrome.driver", "ChromeDriverPath");
    ChromeOptions options = new ChromeOptions();
    options.setBinary(binaryPath);
    options.addArguments("--app=" + argPath);
    options.addArguments("--manifest=" + "https://hostname/quantum/configs/openfin/manfest-uat.json");
    options.setCapability("chromeOptions", options);
    options.setCapability("browserName", "chrome");

    driver = new ChromeDriver(options);
sayhan
  • 1,168
  • 1
  • 16
  • 22
  • Hi Ayhan, really thanks for your quick response, but still cannot start app, here is my code, could you please help check my issue? – yeqing wu Jan 03 '20 at 02:10
  • @yeqingwu options.addArguments("--disable-dev-shm-usage"); add this line to your code. – sayhan Jan 03 '20 at 09:27
  • Still not work, does the chromedriver.exe version have additional requirement? – yeqing wu Jan 03 '20 at 10:19
  • @yeqingwu What if you try it like following options.addArguments("manifest=https://hostname/quantum/configs/openfin/manfest-uat.json"); – sayhan Jan 03 '20 at 10:22