Closed NikitaEgorov closed 3 years ago
chromedriver.exe is not a part of Selenium libs deployed to NuGet, it should be downloaded independently.
Line string location = Path.GetDirectoryName(executingAssembly.Location);
Return incorrect path!!!
https://github.com/dotnet/cli/issues/6261
@barancev
Define "incorrect". Does it return location of the assembly as stated in the comments?
It return %UserProfile%\.nuget\package\selenium.webdriver\...
But should return current application path
Why do think it should? It's the path to the assembly. If you want it to be copied to the bin directory -- configure your project. Libraries should not make a decision whether they have to be copied or not. You should.
Standard path to find all dependencies - current working directory.
1) Please provide a link to this standard for a proof :) 2) Current working dir != project dir, for example if you run tests from Visual Studio using NUnit3 the currect working directory will be somewhere inside the Visual Studio installation directory. 3) geckodriver.exe (an external executable file) is not a dependency.
"The {0} file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at {1}."
I have a new idea
Add directory of assembly to exception message
"The {0} file does not exist in the ***current directory*** or in a directory on the PATH environment variable. The driver can be downloaded at {1}."
Ok.
But
Selenium does not invent new directory. It checks the assembly location, the current working dir and PATH.
current working dir - used only if assembly is embedded! Please, use CWD for all cases
Ah, yes, there is a collision.
/// This method looks first in the directory of the currently executing
/// assembly. If the specified file is not there, the method then looks in
/// each directory on the PATH environment variable, in order.
whereas https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/DriverService.cs#L270 and https://github.com/SeleniumHQ/selenium/blob/master/dotnet/src/webdriver/DriverService.cs#L277 mention "the current directory" that implicitly reads as "the current working directory".
Thank you for perseverance, reopening the issue.
I have the same issue, the workaround is simply to specify .
for driverPath
e.g. ChromeDriverService.CreateDefaultService(".")
.
The GetCurrentDirectory
function is poorly named since it does not get the current directory however I recognise that the current working directory != where the files are always. To me a better solution would be to look in these directories for chromedriver.exe
rather than assuming one directory must have the file based on shadow copy settings etc. Approximately:
string GetDefaultChromeDriverPath()
{
if (ChromeDriverExistsInCwd())
return cwd;
if (ChromeDriverExistsBesideAssemblyLocation())
return assemblyDirectory;
if (ChromeDriverExistsInShadowCopyLocation())
return ...;
if (ChromeDriverExistsInPath())
return ...;
throw new NotFoundException();
}
Personally I placed the PATH
check right at the end because I assume it's a feature to check the file system locations "closer" to the application than in the PATH
i.e. if I have an old version of chromedriver.exe
in my PATH
but one copied to my bin
folder ... please use the bin
folder one.
Anyway, thank you for Selenium and maintaining the code and GitHub issues.
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Error in FileUtilities in Selenium .net
For .net core nuget libs do not copy to bin folder. And WebDriver could not found chromedriver.exe
Workaround:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>