I used ChromeDriver of Selenium to do some automatic tasks. The window form run well in my machine, but when it deployed and user installed window form by ClickOnce. It show error :
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.
Here is the code for create new instance of ChromeDriver:
private static IWebDriver driver = new ChromeDriver();
I searched some solution to add chromedriver.exe in project with specific folder:
private static IWebDriver driver = new ChromeDriver(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ChromeDriver"));
But it didnt' work too. I think ClickOnce prevent exe file when install to client machine. Any solution for this case ? Thanks.
I am not sure how you are getting the chrome driver but here is a suggestion.
Use the chrome driver nuget package
On your Solution name, right click Properties
On Build Tab Add the below:
Conditional compilation symbols: _PUBLISH_CHROMEDRIVER
Output Path: bin\Debug\
Rebuild solution and you should see chromedriver.exe in bin\debug
Then you can use something like this:
case "chrome":
ChromeDriverService service = ChromeDriverService.CreateDefaultService(Path.Combine(GetBasePath, #"bin\Debug\"));
ChromeOptions options = new ChromeOptions();
options.AddArgument("--ignore-ssl-errors=yes");
options.AddArgument("--ignore-certificate-errors");
driver = new ChromeDriver(service, options);
driver.Manage().Window.Size = new System.Drawing.Size(1920, 1280);
break;
Using this will help if you are running locally on C: but may have Jenkins setup on E:
public static string GetBasePath
{
get
{
var basePath =
System.IO.Path.GetDirectoryName((System.Reflection.Assembly.GetExecutingAssembly().Location));
basePath = basePath.Substring(0, basePath.Length - 10);
return basePath;
}
}
Related
when i'm running the selenium test from VS2017 it is able to pick the drivers successfully BUT when i run the same test using mstest command - internally it is referring some other directory!
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\mstest.exe/
testcontainer:..\Test\Sun.TestAutomation.dll /test:"myfristtest"
/resultsfile:..\Test\TestResultLog.trx //Mstest commands
OpenQA.Selenium.DriverServiceNotFoundException: OpenQA.Selenium.DriverServiceNotFoundException: The file
C:\Test\xsed_2018-12-07 10_55_51\Out\chromedriver.exe does not exist.
The driver can be downloaded at
http://chromedriver.storage.googleapis.com/index.html.
code:
this.DriversPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory()));
additional information:
drivers are available in debug folder why my mstest is referring the drivers in "Out" folder ??
This post is a bit old but since it was brought back to the the front, this may help someone.
I would download the ChromeDriver Nuget package. This way you always get the latest version.
Right click on your project > properties. Click on Build tab.
set Conditional compilation symbols = _PUBLISH_CHROMEDRIVER
under output path set: bin\Debug\
Once installed, clean solution and rebuild and you should see the file in the bin dir.
for your chromedriver call it should look something like this:
Driver = new ChromeDriver(Path.Combine(GetBasePath, #"bin\debug"), options);
Then add the GetBasePath code:
public static string GetBasePath
{
get
{
var basePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
basePath = basePath?.Substring(0, basePath.Length - 10);
return basePath;
}
}
This PC -> Properties -> advanced system settings -> Environment variables -> system variables -> Varible PATH add folder, where you have chromedriver.exe
I am using driver chrome for click button programmatically but I can not access to chrome.exe
static IWebDriver driverchromeDriver;
public void chromeDriver()
{
driverchromeDriver = new ChromeDriver(#"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");
driverchromeDriver.Navigate().GoToUrl("http://www.google.com");
driverchromeDriver.FindElement(By.Id("lst-ib")).SendKeys("qwe");
driverchromeDriver.FindElement(By.Id("lst-ib")).SendKeys(OpenQA.Selenium.Keys.Enter);
}
but it shows this problem :
Additional information: The file C:\Program Files (x86)\Google\Chrome\Application\chrome.exe\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html
Apparently it expects a file named "chromedriver.exe" in the directory you specify in the constructor. "chromedriver.exe" seems to be hard-coded in ChromeDriver. If you download chromedriver.exe at the link you provided and change the code to:
driverchromeDriver = new ChromeDriver(#"path where chromedriver.exe is located");
It should work.
As a side note: chromedriver.exe is not the same as Chrome. Chrome is the actual browser and chromedriver.exe is the actual WebDriver for automated testing. So I would not put chromedriver.exe in the same directory as Chrome.
I have an infuriating Selenium error:
The path to the driver executable must be set by the webdriver.chrome.driver system property
Here is the code I am using:
Environment.SetEnvironmentVariable("webdriver.chrome.driver", #"C:\ChromeDriver\chromedriver.exe");
DesiredCapabilities capability = DesiredCapabilities.Chrome();
ChromeOptions options = new ChromeOptions();
options.BinaryLocation = #"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
capability.SetCapability(ChromeOptions.Capability, options);
Uri url = new Uri("http://localhost:5050/wd/hub");
//error on this line
IWebDriver driver = new RemoteWebDriver(url, capability);
I have the driver on disk, at the location.
The selenium server is running, as shown below:
Server
I have added the selenium binary as a system variable, as shown below:
Variables
I have restarted the server too.
What am I missing? It feels as though I am doing everything correctly, but it's not working.
Thanks
With the new selenium, which is 3.0 you should use:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium-server-standalone-3.0.0-beta2.jar
If you are using selenium version below 3.0 you need to reverse the order of selenium with the driver, like:
java -Dwebdriver.chrome.driver=path_to_chrome_driver -jar selenium_server.jar
Also make sure selenium server is compatible with chromedriver.
Other thing to check is that chrome browser is up to date.
I have automation project that run local and also on remote
until now we download the chrome driver version and install it manually to all our remote machines.
Now i want to start use driver nugget , so i download the nugget and instar it into the project , in local it all runs fine , but after I check in the chenges and trying run it on our remote machine I get this error (Im using MSTest):
Initialization method AutomationTests.BoltAPLConsumer.Ini 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..
it looks like the files not exist for some reason on the machine , why it can be ?
this is driver set up cod :
ChromeOptions options = new ChromeOptions();
options.AddArguments("test-type");
options.AddArgument("--disable-popup-blocking");
options.AddArgument("--ignore-certificate-errors");
driver = new ChromeDriver(options);
You need to set the downloaded executable chromedriver.exe current directory on the PATH environment variable then run you above code as it is, or you should provide downloaded executable chromedriver.exe current directory during initialization of ChromeDriver class as below :-
ChromeOptions options = new ChromeOptions();
options.AddArguments("test-type");
options.AddArgument("--disable-popup-blocking");
options.AddArgument("--ignore-certificate-errors");
driver = new ChromeDriver(#"path\to\chromedriver.exe location", options);
Note :- You can download latest chromedriver.exe for here
I have a working script that runs with Firefox but I cannot invoke any other Webdriver browser:
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
driver = new InternetExplorerDriver(); - an exception is thrown
//start setup
driver = new FirefoxDriver();
baseURL = "http://www.google.com";
verificationErrors = new StringBuilder();
//end setup
I get this error:
The IEDriverServer.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://code.google.com/p/selenium/downloads/list.
How do I fix this?
The IEdriver now ships separately as a separate exe as mentioned in the error. You need to download the driver and add it to the PATH env variable as again mentioned in the error. Explanation for the separation of the driver here
More info # https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
The same is the case for the chromedriver. You would need to download it separately while for firefox, this is not the case and hence that is the only driver that works for you.