I'm trying to get a few demo test to run using chrome, but i got the following error:
An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code
Additional information: The HTTP request to the remote WebDriver server for URL http://localhost:57523/session timed out after 60 seconds.
I already added the chromedriver to the solution, first I hardcoded the path when declaring the driver, but then I found this post: Selenium WebDriver.ChromeDriver Nuget package installed, but not working for MSTest and followed some of the steps (from 2 to 4).
This is the code i'm using:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace TestDemo1
{
[TestClass]
public class UnitTest1
{
static IWebDriver driver;
[AssemblyInitialize]
public static void SetUp(TestContext context)
{
//driver = new FirefoxDriver();
driver = new ChromeDriver();
}
[TestMethod]
public void TestMethod1()
{
driver.Navigate().GoToUrl("http://www.hazmeelchingadofavor.com");
}
[TestMethod]
public void TestMethod2()
{
driver.Navigate().GoToUrl("http://www.google.com");
driver.FindElement(By.Id("gbqfq")).SendKeys("Selenium");
driver.FindElement(By.Id("gbqfq")).SendKeys(Keys.Enter);
}
[AssemblyCleanup]
public static void TearDown()
{
driver.Quit();
}
}
}
I'm using VS Express 2013 for Web, in case you were wondering, also when I use the firefox driver, everything works perfectly
EDIT 10/23/2014:
Chrome Version: 38.0.2125.104 m
Chrome Driver: 2.11
Selenium .Net: 2.43.1
Windows: 7 Enterprise 64 bit
It is a known bug: https://code.google.com/p/chromedriver/issues/detail?id=928
try to update to Chrome Driver: 2.12, this version fix another issue:
Resolved issue 916: Selenium (javascript) fails when switching to webview window in Chrome apps [Pri-2] - https://code.google.com/p/chromedriver/issues/detail?id=916
may be it solves your problem. For me downgrading chrome and using old driver solved problem
Found the solution, we put a bit more attention into the error message and found a message about the sockets (can't recall it really good) so we call the IT department and ask for someone to come over, we talked the issue and the possible solution, so the solution:
Long Story Short:
The anti-virus was blocking the chromedriver so it couldn't connect, so the IT guy added a rule to allow full execution on chromedriver and that was it, hours and hours of research and the issue was the anti-virus, if you have a similar problem check with your IT department
Related
I'm new to C# and trying to follow a webscrape tutorial.
Currently i have these software installed:
Visual Studio 2022
.NET.Core 6.0
Selenium.WebDriver(from negut for project?)
Chrome ver.101.0.4951.64
ChromeDriver ver.101.0.4951.41 newest one i can found
Codes are here:
namespace WebScrape
{
class Program
{
static void Main(string[] args)
{
IWebDriver drive = new ChromeDriver();
drive.Navigate().GoToUrl("www.google.com");
}
}
}
After running the code, chrome do open, but only a blank page shown up with url "data:;"
the console shows:
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 12473
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
DevTools listening on ws://127.0.0.1:12476/devtools/browser/cfbbc4af-00d4-45c6-87a0-11cc31baa733
Unhandled exception. OpenQA.Selenium.WebDriverArgumentException: invalid argument
(Session info: chrome=101.0.4951.64)
at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.set_Url(String value)
at OpenQA.Selenium.Navigator.GoToUrl(String url)
at WebScrape.Program.Main(String[] args) in D:\DEV\CSharp_PROJ\WebScrape\WebScrape\Program.cs:line 17
[8060:25652:0512/142113.378:ERROR:device_event_log_impl.cc(214)] [14:21:13.378] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: 连到系统上的设备没有发挥作用。 (0x1F)
Possible solution i have tried:
Try different chromedirver version.(failed)
Download older chrome version to match chromedriver version exactly.(failed)
Please, can I get some help_(:з」∠)_
OpenQA.Selenium.DriverServiceNotFoundException . Tried Installing all the drivers but still showing me the error.
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System.Threading;
namespace lettryanotherone
{
class EntryPoint
{
static void Main(string[] args)
{
IWebDriver ChromeDriver = new ChromeDriver();
ChromeDriver.Navigate().GoToUrl("http://www.OverWorldInnovations.com");
Thread.Sleep(3000);
ChromeDriver.Quit();
}
}
}
Make sure to download Chromedriver which exactly matches Chrome browser version you're using
Unpack chromedriver.exe somewhere in operating system PATH
That should be it, however you might need to restart your console and/or IDE
Instead of step 2 you can also consider using ChromeDriverService class and explicitly provide the location of the chromedriver.exe to the ChromeDriver initialization statement.
// given path to chromedriver is c:\selenium\webdriver\chromedriver.exe
ChromeDriver driver = new ChromeDriver(
ChromeDriverService.CreateDefaultService("c:\\selenium\\webdriver", "chromedriver.exe"));
Selenium C# Tutorial for Beginners
Selenium with C Sharp
Can anybody help with this Selenium error?
I have one C# solution, with only one Specflow feature with one single tests to navigate to an Url using Chrome driver.
When I run the only test it opens Chrome but does not go to the URL, it throws that error :(
Code snippet
namespace MotorClaims.AcceptanceTests.Steps
{
[Binding]
public class Steps
{
public IWebDriver webDriver;
public Steps()
{
webDriver = new ChromeDriver();
}
[Given(#"I am at the motor claim homepage")]
public void GivenIAmAtTheMotorClaimHomepage()
{
webDriver.Navigate().GoToUrl("https://XXXXXXX");
}
Thanks guys, I found the solution for the issue. It was the version of my Chrome driver. I had to downgrade to 2.37 from 2.40. :) .
it seems like the latest version of Chrome driver is problematic with Chrome browser 64.0.3
The Selenium is supposed to work with Firefox without any drivers out of the box, however I found that it is not the case with the latest Selenium & Firefox (install just days ago, Selenium 3 & Firefox ERS 52.5).
I'm following "Selenium C# and NUnit Pain Free Start Guide" as a total newbie, but found the simple Selenium C# NUnit test is not working for Firefox.
Here is my C# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Chrome;
namespace NewSeleniumProject
{
[TestFixture]
public class MyFirstTest
{
IWebDriver driver;
[SetUp]
public void SetupTest()
{
// driver = new ChromeDriver();
driver = new FirefoxDriver();
//driver = new FirefoxDriver(new FirefoxBinary(#"C:\Program Files (x86)\Mozilla Firefox\Firefox.exe"), new FirefoxProfile(), TimeSpan.FromMinutes(10));
//var options = new FirefoxOptions();
//options.BrowserExecutableLocation = #"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
//driver = new FirefoxDriver(options);
}
[Test]
public void myFirstTest()
{
driver.Navigate().GoToUrl("http://www.swtestacademy.com");
Assert.AreEqual("SW Test Academy - Software Test Academy", driver.Title);
driver.Close();
driver.Quit();
}
}
}
And the following are my journeys to get it working.
First of all, the driver = new ChromeDriver() works for me without any hitch.
When I was using 32b Firefox ERS 52 with driver = new FirefoxDriver();, I'm getting the "Unable to determine the current version of FireFox using the registry" error, however none of the answers from Unable to determine the current version of FireFox after updated to 28.0 solves my problem. So I tried the "Try uninstalling Firefox and then re-installing it. That's what I would do" one.
Wit 64b Firefox ERS 52 (and driver = new FirefoxDriver();), I'm getting the "OpenQA.Selenium.WebDriverException : Cannot find Firefox binary in PATH or default install locations. Make sure Firefox is installed." error.
When using the var options = new FirefoxOptions(), for both 32b and 64b Firefox, I'm getting "OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:6985/session timed out after 60 seconds."
Again, the whole setup I'm following is from "Selenium C# and NUnit Pain Free Start Guide". What else I'm missing? Thx.
UPDATE:
This question is not about the error:
OpenQA.Selenium.DriverServiceNotFoundException : The geckodriver.exe file does not exist in the current directory or in a directory on the PATH environment variable.
which I've fixed by downloading the driver from https://github.com/mozilla/geckodriver/releases.
Make sure versions match first. Then try this way of doing for Firefox browser. I faced same challenges before but this way of calling Firefox solved the issue. Hope it might help
var binary = new FirefoxBinary(#"----Firefox.exe Local Path------");
var profile = new FirefoxProfile();
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(#"--GeckoDriver Path-----");
service.FirefoxBinaryPath = #"----Firefox.exe Local Path------";
driverInstance = new FirefoxDriver(service);
So yes, you will need to Dl the driver and place that in your bin folder of your application and pass the path location of the .exe to the driver service using the options() with {}.
I have the same thing, however there is a difference between the two. Firefox is installed in the 64 bit folder and chrome is located in the 32 bit folder (x86) Program Files and i believe this is where there issue lies in the Selenium only looks at the 32 bit folders for the applications .exe.
I ran into the same issue when i started using any other driver apart from edge.
another issue that you may run into with the new gecko driver is that firefox will not open on the requested URL. Note that this was in VB. Should be the same though. I may just run a test.
I use Selenium ChromeDriver in a Unit Test project to test some action on a web page ...
var chromeDriver = new ChromeDriver();
chromeDriver.Navigate().GoToUrl("https://www.google.com");
Chrome driver has been installed from nuget
Install-Package Selenium.WebDriver.ChromeDriver -Version 2.28.0.
When build my project in Visual Studio Online I receive some error:
System.InvalidOperationException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.28.455520
Any solution to solve this?
I don't use the command line to install things for NuGet, I use the menu option in VS.
Open VS and click on your project in the Solution Explorer.
Click on Project > Manage NuGet Packages... from the menu,
See what shows as installed here and if there are any updates. You might try uninstalling and reinstall via the menu I described above and see if it helps. I use NuGet as described all the time and don't have this issue.
ChromeDriver cannot find the Chrome binary files just as the error message indicates. Please check and make sure that Chrome Browser is installed on the build agent or test machine which run the test.
In general chrome will be installed in the path - C:\Program Files (x86)\Google\Chrome\Application
So please check for installation path. If chrome is not in that path then uninstall old one and install chrome using link - http://filehippo.com/download_google_chrome/
The below Nuget packages should be installed
selenium.webdriver
selenium.webdriver.chromedriver
The below code will open chrome and navigate to google page
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Chrome;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://google.com");
}
}
}
You haven't set the path of chromedriver binary in System PATH variable, this how you can do it in code. Do it before you initialize the driver object.
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");