I am trying to automate [electron-api-demos][1]app using this sample code.
public static void main(String args[]) throws IOException, InterruptedException {
int port = 9223;// Open App
Runtime.getRuntime().exec(
"C:\\Program Files\\Sample.exe"
, null, new
File("C:\\Program Files\\Sample"
));
ChromeOptions options = new ChromeOptions();
String remoteDebuggingAddress = "localhost:" + port;
options.setExperimentalOption("debuggerAddress", remoteDebuggingAddress);
options.addArguments("remote-debugging-port=9223");
// options.addArguments("electron-port="+port);
options.setBinary(
"C:\\Program Files\\Sample.exe");
System.setProperty("webdriver.chrome.driver",
"C:\\Users\\narays24\\eclipse-workspace\\xyz\\src\\demo1\\chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
System.out.println(driver.getTitle());
String location = "C:\\Users\\narays24\\eclipse-workspace\\xyz\\src\\demo1";
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
String time = dateFormat.format(now);
File dir = new File(location + time);
if (!dir.exists())
{
dir.mkdir();
}
else
{
//System.out.println("directory already exists");
//Do nothing
}
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(scrFile, new File(location + time + "\\screen1.png"));
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
I am able to access the app and get a screenshot. I am not able to access the cef through the below port :
I am getting the following at the localhost , but not the elements :
Inspectable WebContents scannerui/appfiles/index.html
Can anyone help me understand where I am going wrong. After changing the selenium to alpha , I am able to run this with out errors .
Updated edit :
I am able to navigate to google and automate in cef . But I am not able to control or perform any actions on application's menu bar or buttons or text boxes.
My cef is based on chrome 57 .so I downgraded the chrome browser to 57 , chrome driver to 2.26 and selenium Java libraries to 2.36 .
Still I am not able to click on desktop application specific buttons or text boxes. But am able to driver.navigate to google and perform tests.
Can anyone help here? I am using Java , selenium
I also tried on electron application as mentioned above, still no luck