The below tutorial provides how to do a Selenium automation for Electron js Desktop app in java
I don’t find a good guide for selenium Java with electron application for QA automation. So, I am writing this article to help anyone who is looking for it.
Steps:
- Install Eclipse
- Go to the Electron app release page
- Download the latest chrome webdriver from the above page
- Extract into the location
- Copy the location path and replace into below code
Run the above program and it launches the electron app and prints the window title on the console. That’s a simple sample code I have written. Please use this approach to implement automation in your QA Automation projects.
Update:
Desired capabilities are depreciated so updated the code with below changes. If you face any difficulties, please drop a comment.
package myPackage;
import java.sql.Driver;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Test {
public static void main(String args[]) throws InterruptedException {
ChromeOptions opt = new ChromeOptions();
//Enter the path of your Electron app
opt.setBinary("<directory>\app.exe");
System.setProperty("webdriver.chrome.driver",
"<downloaded_chrome_driver_path>");
WebDriver driver = new ChromeDriver(opt);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
//Printing the window title
System.out.println(driver.getTitle());
}
}
For me it is unable to load dependent nodeJS files for the electron app installed
Can you post your code?
That code is deprecated.
The code part where is that written “WebDriver driver = new ChromeDriver(capabilities);” it’s deprecated
BRO Not able to identify the elements using locators for electron desktop application using selenium web driver. Could you please help out in this?….