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);
Related
Greetings StackOverflow Community,
My issue is simple. I have the following five lines of code, that I can't figure out why Google Chrome doesn't launch google.com when using a custom binary location.
var Chrome = new ChromeOptions();
Chrome.AddArgument("no-sandbox");
Chrome.BinaryLocation = #"C:\GoogleChrome\chrome.exe";
ChromeDriver driver = new ChromeDriver(#"C:\ChromeDriver", Chrome);
driver.Navigate().GoToUrl("https://www.google.com");
Any ideas? All I get is the default chromedriver URL of "data:," when Google Chrome launches.
Why isn't the driver.navigate command working when using a Chrome.BinaryLocation? If I comment out that line, than it works fine.
I am using the following:
Windows 7
Visual Studio Community Edition 2017
Google Chrome version 67
chromedriver 2.41
.NET 4.5 Bindings
hey i dont think you need of binary location
And maybe Chrome is already a type,
try this:
ChromeOptions options = new ChromeOptions();
options.AddArgument("no-sandbox");
var driver = new ChromeDriver(#"C:\GoogleChrome", options);
driver.Navigate().GoToUrl("https://www.google.com");
Okay, I found the answer to this question. I don't know why the Portable version of either Firefox, Chrome or other Chromium based browsers do not function this way, but I resolved this issue by copying the enterprise installation files from program files for Chrome to another directory on the computer and then pointing the Selenium script to use that binary location. Then it worked just fine.
It was also useful to point Chrome to a custom chrome profile location to keep more of the Chrome application from using the local users's AppData folder.
If anyone is interested in accomplishing the same task, I can provide some example code that accomplishes this task. Just message me for more details.
I'm trying to use Selenium 3.5.2 with C #, but I always get the error "Unable to find a matching set of capabilities" every time I try to instantiate the webdriver.
I'm currently using Visual studio 2015 with Selenium 3.5.2, GeckoDriver 0.18 64bit and Firefox 55.0.3 64bit.
Here the code:
var driverService = FirefoxDriverService.CreateDefaultService(DriverPath, DriverName);
driverService.FirefoxBinaryPath = FirefoxPath;
var firefoxOptions = new FirefoxOptions();
var webDriver = new FirefoxDriver(driverService, firefoxOptions, TimeSpan.FromSeconds(10));
webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(0);
webDriver.Navigate().GoToUrl(new Uri("http://www.google.com"));
Where DriverPath, DriverName and FirefoxPath are respectively path of geckodriver executable, geckodriver executable name and firefox executable path (they seems to be fine, when I run the code I can see the firefox slashscreen and geckodriver prompt console).
Does anyone know how to avoid this error?
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 this code. And I put chromedriver.exe in my solution folder bin>>debug
ChromeOptions options = new ChromeOptions();
options.AddArgument("--disable-notifications");
IWebDriver driver = new ChromeDriver(options);
driver.Manage().Window.Maximize();
driver.Url = url;
It works ok when I debug application but after publishing it throws an exception
what can I do? It's simple console application
You should try newer ChromeDriver and Selenium versions. I have just checked this code on Selenium.WebDriver 3.4.0 and Selenium.WebDriver.ChromeDriver 2.30.0.1
Starting ChromeDriver 2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41) on port 2935
Only local connections are allowed.
Press any key to continue . . .
It works fine for debug and release versions.
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.