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.
Related
Is it possible to open my own (normal) chrome browser and have selenium run on this browser?
I saw some existing topics about this wrt. Python: Running Selenium on an existing Chrome Browser Window, how is someone doing this through C# and Selenium?
Type : chrome://version/ in browser you will get executable path of chrome.exe
copy this and close all chrome instance.
**close all chrome instance and **
start chrome as:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=5555
verify chrome is started with port open by going to localhost:5555
Now add remote debugging port as:
var options = new ChromeOptions();
options.debuggerAddress= "127.0.0.1:5555";
var driver = new ChromeDriver(options);
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;
}
}
I have a super simple test script (below) to get started with WebDriver. When I run the test (C# - Visual Studio 2015), it opens up a Firefox browser and then does nothing.
There are several posts out there that talk about the following issue, which I'm also getting:
OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 milliseconds. Attempted to connect to the following addresses: 127.0.0.1:7055.
But those posts regarding this problem are quite old and also have one major difference- their FF browser didn't open; mine does.
The error:
The code:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
namespace seleniumDemo
{
[TestClass]
public class UnitTest1
{
static IWebDriver driverFF;
[AssemblyInitialize]
public static void SetUp(TestContext context)
{
driverFF = new FirefoxDriver();
}
[TestMethod]
public void TestFirefoxDriver()
{
driverFF.Navigate().GoToUrl("http://www.google.com");
driverFF.FindElement(By.Id("lst-ib")).SendKeys("Selenium");
driverFF.FindElement(By.Id("lst-ib")).SendKeys(Keys.Enter);
}
}
}
This question is different from what's been suggested as a duplicate because the FireFox browser actually opens in this case. In the other questions, it wasn't responding at all.
it seems to be related to Selenium and Firefox version incompatibility. I also faced the same error when selenium on my machine was unable to communicate to firefox. I upgraded firefox to 46.x and it started working.
You can find version compatibility information over web or refer selenium changelog as well.
Use MarrioneteDriver to use latest version of Firefox.
Below is the Java code, you can write in C# accordigly (Make sure you have geckodriver.exe under BrowserDriver folder in your project folder)
System.setProperty("webdriver.gecko.driver", System.getProperty("user.dir")+"/BrowserDrivers/geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
WebDriver driver = new MarionetteDriver(cap);
You can download latest version of MarrioneteDriver from below :
https://github.com/mozilla/geckodriver/releases
And you should Marionette executable to Windows system path :
To add the Marionette executable to Windows system path you need
update the Path system variable and add the full directory to the
executable.
To do this, right-click on the Start menu and select System. On the
left-side panel click Advanced system settings and then Environment
Variables button from System Properties window. Now the only step left
to do is to edit Path system variable and add the full directory to
your geckodriver (you may need to add a semi-colon before doing this,
if not already present) and you’re good to go.
Then simply create your driver instance :
var driver = new FirefoxDriver(new FirefoxOptions());
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