1

I am creating a class Library using .NetStandard and I have downloaded the following from the Selenium package from the NuGet Store

enter image description here

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

enter image description here

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.

Jamisco
  • 1,658
  • 3
  • 13
  • 17
  • What flavor of .net are you using for the console app? and what version of .Net Standard are you using? – Edd Apr 23 '21 at 17:56
  • 1
    Also, not sure it's a good practice to have 'spaces' in your namespaces. Especially for class libs that don't get user's eyes on them. I know that VS automatically puts underscores in their place, but you don't want to get burned by this. Could make debugging very difficult, if it happens to play a part. – Edd Apr 23 '21 at 18:19
  • 1
    @Edd Im using .Net Standard 2.0 – Jamisco Apr 24 '21 at 14:28

1 Answers1

0

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).

Screen shot of test project

EDIT: Your output/bin folder should look something like the following:

enter image description here

... and your .csproj file for your reference lib should have at least the follow: enter image description here

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?

Edd
  • 703
  • 7
  • 23
  • I appreciate your feedback, but I never intended it to be a full answer, I just hope it helps in the littlest bit. It was the only way I could post a screenshot showing all the libs being used. Thanks for your valuable contribution :) – Edd Apr 24 '21 at 04:15
  • 1
    Well we have ruled out its definetely not a problem with .Net Core or Standard, What are some other possibilities – Jamisco Apr 24 '21 at 14:31
  • 1
    Can you confirm that the .dll is copied to your bin/output folder? – Edd Apr 24 '21 at 14:32
  • 1
    @Edd Sorry for the late reply, I have work and school. Anyways, Thank you very much for that comment, That was all I needed to be sent towards the right Path. After that comment, I looked up the appriopriate questions and got the answers https://stackoverflow.com/questions/58085571/nuget-pkg-dlls-missing-from-build-folder-in-net-standard-dll-project-dlls-are The first answer to that question solved my problem. If you would please edit your answer to add "true" just right under targetframework, that would be great – Jamisco Apr 26 '21 at 20:13
  • 1
    only then can i mark this answer as "solved my problem" Thank you! – Jamisco Apr 26 '21 at 20:14