2

I am trying to automate testing of an electron application (from third party vendor) using Selenium and C# and am getting the error: OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:. Attached is the piece of code.

        ChromeOptions options = new ChromeOptions();
        ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\Selenium\chromedriver_win32_1", 
        @"<path to exe of electron application>");
        options.AddArgument("–no-sandbox");
        options.AddArgument("–disable-dev-shm-usage");
        driver = new ChromeDriver(chromeService, options, TimeSpan.FromSeconds(180));

Actual result: OpenQA.Selenium.WebDriverException : Cannot start the driver service on http://localhost:

Expected Result: driver instance is created successfully

NOTE: The electron application is launched successfully. Also when I remove the path to exe of electron application there is no error and driver instance is created successfully

  • [Here](https://stackoverflow.com/questions/51136304/linking-selenium-with-electron-framework-c) is the answer, which is working. Think, you can use it. – Ukrainis Feb 18 '19 at 07:52

1 Answers1

0

There can be different problems but when I am testing electron apps, I prefer to use following kind of options to set binary. Maybe following kind of code block can solve your issue.

ChromeOptions options = new ChromeOptions();
    options.setBinary(binaryPath);
    options.addArguments("--app=" + argPath);
    options.AddArgument("–no-sandbox");
    options.AddArgument("–disable-dev-shm-usage");
    options.setCapability("chromeOptions", options);
    driver = new ChromeDriver(options); 
slckayhn
  • 1,083
  • 11
  • 20
  • Thanks for the response. Based on your inputs I tried below code: ChromeOptions options = new ChromeOptions(); ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\Selenium\chromedriver_win32_1"); options.BinaryLocation = @""; //options.addArguments("--app=" + argPath); options.AddArgument("--no-sandbox"); options.AddArgument("–disable-dev-shm-usage"); driver = new ChromeDriver(chromeService, options); – user_11077035 Feb 18 '19 at 14:59
  • This time I got the error: Message: OpenQA.Selenium.WebDriverException : unknown error: DevToolsActivePort file doesn't exist (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.16299 x86_64) – user_11077035 Feb 18 '19 at 15:00
  • Can yo please try to put top "-no-sandbox" option. @may04pat05 – slckayhn Feb 18 '19 at 15:13
  • Tried this: ChromeOptions options = new ChromeOptions(); ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\Selenium\chromedriver_win32_1"); options.AddArgument("--no-sandbox"); options.AddArgument("–disable-dev-shm-usage"); options.BinaryLocation = @"C:\Program Files\Authoring Suite\OTX Authoring Suite 2.0.exe"; //options.addArguments("--app=" + argPath); driver = new ChromeDriver(chromeService, options, TimeSpan.FromSeconds(180)); – user_11077035 Feb 18 '19 at 15:20
  • Got below error: Message: OpenQA.Selenium.WebDriverException : unknown error: DevToolsActivePort file doesn't exist (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.16299 x86_64) – user_11077035 Feb 18 '19 at 15:20
  • It is about binary location. set "@"C:\Selenium\chromedriver_win32_1" as a binaryPath. @may04pat05 – slckayhn Feb 18 '19 at 15:34
  • Okay, but I am trying to test an electron application using the driver. If I provide the binary location as path to chrome driver exe then where should I specify the exe for electron application. Can you please suggest – user_11077035 Feb 18 '19 at 16:45
  • You can specify your “-app” argument as a electron app path. @may04pat05 – slckayhn Feb 18 '19 at 16:47
  • This does not work for me: ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.BinaryLocation = @"C:\Selenium\chromedriver_win32_1\chromedriver.exe"; //ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\Selenium\chromedriver_win32_1"); driver = new ChromeDriver(chromeOptions); – user_11077035 Feb 18 '19 at 18:34
  • Error thrown: Message: OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: was killed (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Selenium\chromedriver_win32_1\chromedriver.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.16299 x86_64) – user_11077035 Feb 18 '19 at 18:35
  • This does work for me: ChromeOptions chromeOptions = new ChromeOptions(); //chromeOptions.BinaryLocation = @"C:\Selenium\chromedriver_win32_1\chromedriver.exe"; ChromeDriverService chromeService = ChromeDriverService.CreateDefaultService(@"C:\Selenium\chromedriver_win32_1"); driver = new ChromeDriver(chromeService, chromeOptions); – user_11077035 Feb 18 '19 at 18:35
  • To summarize I am not able to set the chrome driver executable path using BinaryLocation but am able to do so using ChromeDriverService. Any help regarding this please ? – user_11077035 Feb 18 '19 at 18:44
  • I am sorry but I have no other solution for this. – slckayhn Feb 18 '19 at 18:55