'Electron+Selenium+Java. Run electron app with parameters (like in windows shortcut)
I am working on automation for Electron app using Selenium + Java.
Java test class for demo electron app works good (snippet is below).
The problem is, that my real application on Windows should be launched with json configuration file. And the path to this config file set up in the SHORTCUT parameter.
Example how it works for the shortcut:
C://AppExample/Desktop/app.exe --param=config.json
Test class for demo electron app
@Test
public void test() throws InterruptedException {
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.setBinary("C://AppExample/Desktop/app.exe");
options.setCapability("chromeOptions", options);
options.setCapability("setBrowserName", "chrome");
driver = new ChromeDriver(options);
if (driver.findElements(By.id("button-about")).size() > 0)
driver.findElement(By.id("button-about")).click();
driver.findElement(By.id("get-started")).click();
List<WebElement> elements = driver.findElements(By.className("nav-button"));
for (WebElement element : elements) {
element.click();
}
driver.quit();
}
I tried to set custom capability but it doesn't work.
options.setCapability("--param","=config.json");
Is there a way to run electron app with parameters (like parameters in windows shortcut) in selenium?
Solution 1:[1]
I found the solution. First, I need to use WinappDriver+Appium+Selenium Java stack.
The second: Solution about parameters is here https://github.com/microsoft/WinAppDriver/issues/1323
So the code will be like that:
dc = {
'app': App,
'platformName': 'Windows',
'platformVersion': '10',
'automationName': 'Windows',
"appArguments": "-- config=file.json",
'appWorkingDir': "path to your file.json"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TemirlanU |
