-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Description
Description
When attempting to use WebDriver.dll, PowerShell displays the following message:
Could not load file or assembly 'System.Text.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
This issue is being submitted as requested by nvborisenko in a comment on a related issue (#14600).
Steps to Reproduce the Problem
Obtain a computer with the required Windows applications:
- Obtain a computer with Windows PowerShell 5.1 (e.g. Windows 11).
- Launch Windows PowerShell.
- Copy the following command to the Windows PowerShell window and run the command.
[System.Runtime.InteropServices.RuntimeInformation]::FrameworkDescription - Confirm that you see something like ".NET Framework 4.8.9310.0". The text after "4.8." can be ignored.
- Close Windows PowerShell.
Get the NuGet package:
- Go to https://www.nuget.org/api/v2/package/Selenium.WebDriver/4.38.0.
- (optional) Click on "Frameworks". The web page will say that .NET Framework 4.8 and .NET Framework 4.8.1 are "Compatible target framework(s)".
- Download the package by clicking on "Download package".
- Create a new folder for the files that will be obtained in the following step. This will be called the "Working Directory".
Get the Selenium files for .NET Framework 4.8:
- Change the download's file extension to "zip" and open the file.
- Extract the contents of the ZIP file to a new folder.
- Open the folder that was created in the previous step.
- Open the "lib" folder.
- Open the "netstandard2.0" folder. Microsoft says the files in this folder should work with .NET Framework 4.8 (https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0).
- Copy all the files in the "netstandard2.0" folder to the Working Directory.
- Return to the folder that was created at step 2.
- Open the "runtimes" folder.
- Open the "win" folder.
- Open the "native" folder.
- Copy the contents of the "native" folder to the Working Directory.
- Confirm that the root of the Working Directory contains at least 1 "EXE" file and at least 1 "DLL" file.
- (Optional) Delete the two ZIP files.
Tell Selenium where to find Selenium Manager as documented at https://www.selenium.dev/documentation/selenium_manager/#configuration:
- Launch Windows PowerShell 5.1.
- Copy the following script and paste it in the window. Then run the script. The script will determine if the environment variable has been already configured.
$SeleniumManagerPathEnvironmentVariablePath = Join-Path `
-Path "Env:" `
-ChildPath "SE_MANAGER_PATH"
$ParametersToTestSeleniumManager = @{
Path =
$SeleniumManagerPathEnvironmentVariablePath
ErrorAction ="SilentlyContinue"
}
$SeleniumManager = Get-Item `
@ParametersToTestSeleniumManager
if ($null -eq $private:seleniumManager) {
Write-Output "The Selenium Manager Path environment variable has not been set."
}
else {
Write-Warning "The Selenium Manager Path environment variable is set to `"$($SeleniumManager)`"."
Write-Warning "This might not be the correct path."
}
- If PowerShell reports that the environment variable has not been set, copy the following script and paste it in the window. Then run the script. The script will set the variable:
# Will not persist after the PowerShell window closes
# per
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.4#saving-changes-to-environment-variables
# .
# However, it will persist in the PowerShell window
# even after the script terminates.
$SeleniumManagerPath = Read-Host -Prompt "What is the path of the Selenium Manager file? Include the file extension. Do not include quotation marks around the path."
New-Item -Path "Env:" `
-Name "SE_MANAGER_PATH" `
-Value $SeleniumManagerPath |
Out-Null
- Copy the script from the section titled "Reproducible Code" to the PowerShell window. Run the script.
System Information
Microsoft Windows Version 22H2 (OS Build 19045.6456)
Output From $PSVersionTable in PowerShell:
Name Value
---- -----
PSVersion 5.1.19041.6456
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.6456
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Reproducible Code
$WorkingDirectoryPath = Read-Host -Prompt "Enter the full path of the Working Directory. Do not use quotation marks."
$WebDriverPath = Join-Path -Path $WorkingDirectoryPath -ChildPath "WebDriver.dll"
Import-Module $WebDriverPathℹ️ Last known working version: The file properties for the working version of WebDriver.dll says its file version is "4.0.0.0". Its Product version is "4".