Selenium for Electron Applications

0_WMsq_uI0pTnauBUs

     Electron allows for the development of desktop GUI applications using front and back end components originally developed for web applications: Node.js run-time for the back-end and Chromium for the front-end.

    Electron uses HTML, JavaScript and CSS to build desktop applications. The vision of same codebase for web, mobile and desktop applications has never been closer.

   There is a small difference in the driver creation section when we compare with normal driver instantiation. Once the driver creation done; rest of the automation script executions are same as Selenium. Here I am explaining the driver creation for old and new selenium versions:

New selenium version(3.7.x) method driver creation in Electron Applications:

WebDriver driver;
System.setProperty(“webdriver.chrome.driver”, “pathTochromedriver”);
ChromeOptions options = new ChromeOptions();
options.setBinary(“pathToElectronApplication”);
ChromeDriverService chromeservices = new ChromeDriverService.Builder().build(); driver = new ChromeDriver(chromeservices, options);

Old selenium version method for driver creation in Electron Applications:

WebDriver driver;
System.setProperty(“webdriver.chrome.driver”, “pathTochromedriver”);
ChromeOptions options = new ChromeOptions();
options.setBinary(“pathToElectronApplication”);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“chromeOptions”, options ); capabilities.setBrowserName(“chrome”);
driver = new ChromeDriver(capabilities);

Shortcut to open inspect mode in Electron Applications,

Windows: Ctrl+Shift+i

MAC: Command+Alt+i

make it perfect !