I am creating a class Library using .NetStandard and I have downloaded the following from the Selenium package from the NuGet Store
Now I have a simple test code
using System;
using Operation_Forage_V2;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
public class test
{
public static void Main(string[] args)
{
Uri Aurl = new Uri("https://www.youtube.com/");
IWebDriver aDriver;
aDriver = new ChromeDriver();
aDriver.Url = Aurl.OriginalString;
var element = aDriver.FindElement(By.ClassName("sa_wr"));
var innerHtml = element.GetAttribute("innerHTML");
Console.WriteLine(innerHtml.Substring(0, 100)); //just to see if it got the html
}
}
The problem is when I run the code (as console application), I get the following error
Ive seen similar problems on this websites, but they did not help me
I have no idea why this error is occurring especially given the driver and the right version of the driver has been downloaded using NuGet and the picture clearly shows it.
I don't believe this is an issue with .Net Standard, as I was able to get it loaded, but got a different error, as I have a more recent version of Chrome running, but I was able to load the assemblies fine using Class Lib (.Net Standard 2.0.3) and Console App (.Net Core 3.1).
EDIT: Your output/bin folder should look something like the following:
... and your .csproj file for your reference lib should have at least the follow:
Edit #2: I just noticed from your nuget packages screenshot above that you have warnings on them. Please delete remove you references and try adding them back, or if you right click your project is VS there should be an option to redownload your packages, but I never have much success with the ladder method. However it does seem to be an issue with you packages. If these don't work for you, please try removing your bin and obj folders and rebuild, sometimes this can help. If you still have issues, please share the ⚠️ messages as they might assist in debugging.
Edit #3: You may also want to try and see if adding this <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
to you .csproj file as explained here might help: Nuget Pkg Dlls Missing from Build Folder in .Net Standard DLL Project. dlls are Not Copy Local? Fix in Visual Studio 2019?