Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
frankh
Posts : 4
Join date : 2017-02-10

Selenium webdriver in VS: Adding chromedriver with NuGet doesn't work very well Empty Selenium webdriver in VS: Adding chromedriver with NuGet doesn't work very well

Tue May 09, 2017 4:05 pm
VS never ceases to amaze me. Or, rather, it never ceases to amaze me how I either forget how to do things between each time I create a new solution, or how things seem to change in between solutions.

I'm trying to use ChromeDriver with Selenium (in C#). I've installed the Selenium.Webdriver and Selenium.Chrome NuGet packages in the project, and everything seems fine. No errors on the using directives, and no errors when trying to create a new ChromeDriver.

Here's the Selenium driver code:

Code:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;

...

public class GCDriver {
    public static IWebDriver Instance { get; set; }

    public static void Initialize () {
        Instance = new ChromeDriver();
    }

    public static void Wait(TimeSpan timeSpan) {
        Thread.Sleep((int)(timeSpan.TotalSeconds * 1000));
    }

    public static void Close() {
        Instance.Quit();
    }
}
When trying to start (initialize) the ChromeDriver as I always do, I get this error:

Code:
Test Name:  One
Test FullName:  MyTests.TestUnitTest1.One
Test Source:    C:\Users\149999frho\Source\Workspaces\QA\Automation\MyTests\TestUnitTest1.cs : line 17
Test Outcome:   Failed
Test Duration:  0:00:00,0118783

Result StackTrace:  
at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String    executableName, Uri downloadUrl)
   at OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeOptions options)
   at OpenQA.Selenium.Chrome.ChromeDriver..ctor()
   at Automation.GCDriver.Initialize() in C:\Users\149999frho\Source\Workspaces\QA\Automation\Automation\Selenium\GCDriver.cs:line 16
   at MyTests.TestUnitTest1.Init() in C:\Users\149999frho\Source\Workspaces\QA\Automation\MyTests\TestUnitTest1.cs:line 12
Result Message: Initialization method MyTests.TestUnitTest1.Init threw    exception. OpenQA.Selenium.DriverServiceNotFoundException:    OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does    not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html..

The thing is, the chromedriver.exe IS located in the Solution\Project\Automation\bin\Debug folder. As it should be, since the NuGet package(s) is installed.

What am I missing here? Do I have to add any other references after installing the NuGet package? Adding the chromedriver.exe file as a normal reference is not possible, btw - VS complains about it not being an actual COM reference or something like that. Adding it "manually" as an external reference in the project results in two instances of chromedriver being started at the same time, and then it becomes unusable becuase VS insists that the files is in use the next time I try to run it. (Switching between Release and Debug in VS works only once in that case.)

The references seems to be in order, though - and the references folder looks EXACTLY the same as in the other solution where things are working:

...
WebDriver
WebDriver.Support

(In the solution I have where things are working fine, there is no ChromeDriver mentioned in the project references either. I take it this is due to using NuGet.)

There is a workaround, albeit a poor one: Adding the path to the chromedriver.exe file when creating a new instance of ChromeDriver. Instance = new ChromeDriver(). However, this is auseless solution, as I have to use the absolute path - VS doesn't accept a relative one. When sharing a project it will be downright impossible to manage.
So the problem is that the project doesn't know where the file installed by it's own NuGet package manager resides.

Anyone got any ideas?

sdfsdf
avatar
frankh
Posts : 4
Join date : 2017-02-10

Selenium webdriver in VS: Adding chromedriver with NuGet doesn't work very well Empty Re: Selenium webdriver in VS: Adding chromedriver with NuGet doesn't work very well

Fri May 12, 2017 2:58 pm
I'm deleting this, as it seems to be the same way as with all questions of a certain complexity: No one knows.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum