Linking selenium with electron framework (c#)
Spectron with mocha is supposed to be faster.
But still here is what you need.This is Java & Selenium.
System.setProperty("webdriver.chrome.driver","C:\\electron-chromedriver\\bin\\chromedriver.exe");ChromeOptions chromeOptions = new ChromeOptions();chromeOptions.setBinary("C:\\Users\\app.exe");chromeOptions.addArguments("start-maximized");DesiredCapabilities capability = new DesiredCapabilities();capability.setCapability(CapabilityType.BROWSER_NAME, "Chrome");capability.setCapability("chromeOptions", chromeOptions); driver = new ChromeDriver(chromeOptions);
I have used the packaged electron app for binary (i.e) app.exe .
I think this is what you need.
Described below is related to using of Electron with .Net C# OpenQA.Selenium.
If you want to run electron app which being developed (consists of files index.html, main.js, etc.) you have to add following options (pay attention to 'app=' in cmd argument):
var options = new ChromeOptions();options.BinaryLocation = @"your_path_to_electron\electron.exe";options.AddArgument(@" app=path_to_folder_with_your_electron_app_src");
But if you want to run packaged electron app (*.exe) it is enough to use:
var options = new ChromeOptions();options.BinaryLocation = @"path_to_folder_with_your_electron_app\your_electron_app.exe";
Also you can start any version of chromedriver.exe:
var service = ChromeDriverService.CreateDefaultService(path_to_folder_with_driver);var driver = new ChromeDriver(service, options);
It might be helpful because I know that different electron applications are built on using of different version's drivers.
Try this for Electron application Initialization:
using NUnit.Framework;using OpenQA.Selenium;using OpenQA.Selenium.Chrome;using System;namespace Selenium_Demo{ class Selenium_Demo { IWebDriver driver; [SetUp] public void Start_Browser() { ChromeOptions options = new ChromeOptions(); ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\\selenium\\chromedriver_win32v\\chromedriver.exe", @"C:\\Program Files\\Cerebrata\\Cerebrata.exe"); driver = new ChromeDriver(chromeService, options); } [Test] public void Test() { System.Threading.Thread.Sleep(6000); Console.WriteLine("Test Passed"); } [TearDown] public void Close_Browser() { driver.Quit(); } }}