Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest

后端 未结 7 504
予麋鹿
予麋鹿 2020-12-17 16:06

I have added the WebDriver.ChromeDriver nuget package to my solution, which contains the ChromeDriver.exe file, required for Selenium WebDriver to run automated tests using

相关标签:
7条回答
  • 2020-12-17 16:22

    The Nuget package will place the driver.exe file in {buildconfiguration}/ To tell it to look in the root of the application, pass a "." when creating a new instance of the driver.

    IWebDriver driver = new ChromeDriver(".");
    
    0 讨论(0)
  • 2020-12-17 16:23

    I set it to "Copy", which always which resulted in error when I try to rebuild it. Setting it to "Copy if newer" works fine.

    0 讨论(0)
  • 2020-12-17 16:25

    its resolves the issue :

    IWebDriver driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
    
    0 讨论(0)
  • 2020-12-17 16:31
    IWebDriver driver = new ChromeDriver("C:\\Folder_with_Chrome_driver");
    

    Download related driver and add local path.

    0 讨论(0)
  • 2020-12-17 16:38

    I wouldn't bother with the NuGet package for this, simply because this is not a class library - which is technically, what NuGet is all about. ChromeDriver has also been updated many times since that release.

    Anyway, I would say that I have just done the same thing to see what the issue is:

    1. Download NuGet package
    2. Using Visual Studio, add a new item to the project by right-clicking on the project -> Add Item -> Existing Item
    3. Navigate and select the chromedriver.exe
    4. Change the properties to ensure "Copy to Output Directory" is set to Copy always.

    You are probably falling down on point 4. That setting is set to Do not copy by default.

    0 讨论(0)
  • 2020-12-17 16:38

    I had similar problem solved it by these 3 steps

    1.Goto google chrome drivers official site https://sites.google.com/a/chromium.org/chromedriver/downloads download and unpack

    2.Goto Visual Studio solution explorer click add -> existing file -> select chrome driver

    3.Right click on chrome driver in VS and select properties set it to always copy

    0 讨论(0)
提交回复
热议问题