- frankh
- Posts : 4
Join date : 2017-02-10
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:
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
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();
}
}
- 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
- frankh
- Posts : 4
Join date : 2017-02-10
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.
- error set cookies on chromedriver this selenium-webdriver node js
- I downloaded and installed Selenium WebDriver Jar files in my Eclipse, but still i am facing issues and couldn't run the webdriver scripsts.
- webdriver double click doesn't work
- Selenium IDE generated testcase script is not working in Selenium Webdriver
- Adding with selenium IDE
Permissions in this forum:
You cannot reply to topics in this forum