Selenium C# / ChromeDriver : Cannot start the driver service

796 views
Skip to first unread message

Arnaud Rigole

unread,
Aug 5, 2022, 9:57:00 AM8/5/22
to ChromeDriver Users
Hi everyone,

I cannot get Selenium & Chrome work on a WS2016, with the following dependencies versions:

- .NET Framework 4.5 installed
- Latest Chrome 104.0.5112.81, entreprise version, installed in %programfiles(x86)%
- Latest Selenium webdrive & support packages 4.0.3
- Chromedriver v104.0.5112.79

Here is the PowerShell code i use to run Selenium...

    # make sure chrome & chromedriver is not already running
    taskkill /f /im chromedriv*

    # set path as its a prerequisite, this path contains the selenium .dll's & chromedriver binary
    $workingPath = "C:\users\(redacted)\documents\devs\script"
    if (($env:Path -split ';') -notcontains $workingPath) {
        $env:Path += ";$workingPath"
    }

    # load the selenium classes
    Add-Type -Path "$($workingPath)\WebDriver.dll"

    $ChromeDrvOptions = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService()

    # tried to add some logging, it logs nothing more than the console output :(
    $ChromeDrvOptions.LogPath = "$workingPath\logging\chromedriver.log"
    $ChromeDrvOptions.EnableVerboseLogging = $true
    $ChromeDrvOptions.EnableAppendLog = $true

    # tried with & without increasing the launch timeout as i could read on other forums threads...
    $ts = new-timespan -minutes 3
    $ChromeDrvOptions.InitializationTimeout=$ts

    # tried with & without specific port, made sure that its not used already
    $ChromeDrvOptions.Port=5555
   
   
    $ChromeOptions = [OpenQA.Selenium.Chrome.ChromeOptions]::new()
    $ChromeOptions.AddArguments("user-data-dir=$workingPath\chromeprofile")
    $ChromeOptions.AddArguments('--profile-directory=Default')
    $ChromeOptions.AddArguments('start-maximized')
    $ChromeOptions.BinaryLocation = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
   
    #$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)
    $ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeDrvOptions,$ChromeOptions)

The result is...

    Starting ChromeDriver 104.0.5112.79 (3cf3e8c8a07d104b9e1260c910efb8f383285dc5-refs/branch-heads/5112@{#1307}) on port 5555
    Only local connections are allowed.
    Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
    ChromeDriver was started successfully.
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    Impossible de se connecter au serveur distant
    New-Object : Exception lors de l'appel de «.ctor» avec «2» argument(s): «Cannot start the driver service on
    http://localhost:20066/»
    Au caractère Ligne:32 : 18
    +         return @(& $origNewObject @psBoundParameters)
    +                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation : (:) [New-Object], MethodInvocationException
        + FullyQualifiedErrorId :ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

i'm running out of ideas... without more logging options i dont even have a clue of the potential problem source...

Thanks in advance,  
Arnaud

Amol Sonawane

unread,
Jan 16, 2023, 3:41:09 AM1/16/23
to ChromeDriver Users
Hi, please help me on this, I am also getting similar issue!
Reply all
Reply to author
Forward
0 new messages