selenium: [๐Ÿ› Bug]: Dotnet Error in 4.11.0 when using ChromeDriverService.CreateDefaultService()

What happened?

When using ChromeDriverService.CreateDefaultService() to instantiate a ChromeDriver, the error โ€œUnable to obtain chrome using Selenium Managerโ€ occurs. This started happening in 4.11.0, but was fine in 4.10.0.

How can we reproduce the issue?

# This PowerShell code should be saved as a file with a ".ps1" extension. It uses the C# Nuget Packages' DLLs.
# They can be obtained by downloading the Nuget packages as ZIP files (https://www.nuget.org/packages/Selenium.Support/ and https://www.nuget.org/packages/Selenium.WebDriver) and copying the DLLs from the lib\net45 folder inside each ZIP file.

Function New-ChromeDriver {
    [CmdletBinding(
        SupportsShouldProcess,
        ConfirmImpact = 'Low'
    )]
    param(
        [Parameter(Mandatory)][string]$ScriptPath
    )
    $private:result = $null
    Initialize-Selenium -ScriptPath $ScriptPath
    $private:chromeDriverService = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService()
    $private:chromeDriverService.DriverServicePath = $ScriptPath

    $private:chromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
    $private:chromeOptions.AddExcludedArguments("excludeSwitches", "enable-logging");

    if ($PSCmdlet.ShouldProcess("Create a new instance of ChromeDriver.")) {
        $private:result = New-Object -TypeName OpenQA.Selenium.Chrome.ChromeDriver -ArgumentList @($private:chromeDriverService, $private:chromeOptions)
    }

    $private:result
}

Function Initialize-Selenium([string]$ScriptPath) {
    #Required for Chrome
    if (($env:Path -split ';') -notcontains $ScriptPath) {
        $env:Path += ";$ScriptPath"
    }

    Import-Module "$($ScriptPath)\WebDriver.dll"
    Import-Module "$($ScriptPath)\WebDriver.Support.dll"
}

$FolderWithDllsAndChromeDriverExecutable = Read-Host -Prompt "Which folder has the WebDriver DLLs and ChromeDriver executable file?"
New-ChromeDriver -ScriptPath $FolderWithDllsAndChromeDriverExecutable

Relevant log output

https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/ says ".NET does not currently have a Logging implementation".

Operating System

Windows 10

Selenium version

4.11.0

What are the browser(s) and version(s) where you see this issue?

Version 116.0.5845.97 (Official Build) (64-bit)

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 116.0.5845.96 (1a391816688002153ef791ffe60d9e899a71a037-refs/branch-heads/5845@{#1382})

Are you using Selenium Grid?

No

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 46 (25 by maintainers)

Most upvoted comments

I think we can close it because of initially it was about 4.11. Many things have been improved, letโ€™s force people to post new issue instead of adding new comments here.

@StevenTN615 @nvborisenko

Okay I have updated my code to show ex.toString(). Iโ€™ll provide the exception details again if it occurs anytime soon as this issue is random for me.

All my .dlls are in same folder. Please see attached screenshot. Files