I am using:
chromedriver=2.26.436362
Chrome Version 55.0.2883.87 m (64-bit)
.Net C# 4.6.1 / Visual Studio 2015 Community Edition
I am seeing the following exception during website testing (this is my log4net entry):
FATAL2017-01-09 05:03:10 – no such session
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64)
FATAL2017-01-09 05:03:10 – at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args)
at OpenQA.Selenium.Remote.RemoteWebDriver.ExecuteScript(String script, Object[] args)
I start my driver session like this:
var options = new ChromeOptions();
options.AddArguments("test-type");
options.AddArgument("incognito"); // works
options.AddArgument("--disable-bundled-ppapi-flash"); // works! this turns off shockwave
options.AddArgument("--disable-extensions"); // works
options.AddArguments("--start-fullscreen");
var driver = new ChromeDriver(options);
driver.Manage().Cookies.DeleteAllCookies();
return driver;
And I navigate to a "new" tab in Chrome with the following command:
lock (Session.Driver)
{
JavaScriptExecutor jscript = Session.Driver as IJavaScriptExecutor;
jscript.ExecuteScript(string.Format("window.open('{0}', '_blank');", url));
}
Which works in DEBUG 100% of the time. In RELEASE mode, I receive the error above. Which makes this a difficult problem to resolve...no debugger.
I have checked and the session is active, and at the point of entry two handles in Driver.WindowHandles corresponding to the tabs in Chrome are available. I have resorted to Console.Writeline() statements to view variables that I would normally diagnose in the watch window in visual studio debug mode.
I have been unable to reproduce this exception while debugging. It always "works" during debugging.
There are 5-10 other SO posts about the same issue. The answers to those questions involved updating the chromedriver.exe (I have the latest, and also tried older versions), or, are working with a different technology stack. There must be something else going on here.
Notes:
I can reproduce this error every time in RELEASE mode. However in DEBUG mode it works every time (no error).
I tried downgrading to chrome32_53.0.2785.116 (I uninstalled version 54) - same results no improvement.
I checked which chrome driver I'm using for DEBUG: it is exactly the same chromedriver.exe used during RELEASE. (this leads me to conclude that neither Chrome, nor the Chrome driver, are the culprit).
I discovered that I had to remove "optimize code" setting from Project->Properties->Build->(Release Configuration)->uncheck "optimize code".
I do not know why the "optimize code" setting would cause this issue.
I cannot claim credit. I followed the instructions at this SO post for the solution. See Josh Berke's post.
Found same error when running ChromeDriver in multithreading.
Try to add:
ChromeOptions chromeOptions = new ChromeOptions();
.....
chromeOptions.AddArgument("--disable-impl-side-painting"); //it worked for me
.....
var tmp = new ChromeDriver(service, chromeOptions);
Related
For compatibility reasons I prefer to use Chrome version 55.0.2883.75 with Chromedriver v. 2.26. I downloaded the older version of chrome from https://www.slimjet.com/chrome/google-chrome-old-version.php and Chromedriver 2.26 from https://chromedriver.storage.googleapis.com/index.html?path=2.26/.
I am using the following code to attempt to set my Chrome binary location:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)
However, when I attempt to launch the WebDriver Python returns the following error:
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
I have tried searching through similar questions and answers but have not had any luck so far. Any help is greatly appreciated - thank you in advance!
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The server expects you to have Chrome installed in the default location for each system:
OS
Expected Location of Chrome
Linux
/usr/bin/google-chrome1
Mac
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP
%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista and newer
C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
Using a Chrome executable in a non-standard location
However you can also override the default Chrome binary location as follows:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
Related Docs
Reference
You can find a detailed discussion in:
Is Chrome installation needed or only chromedriver when using Selenium?
What happened to me is that I didn't have chrome, the main browser, installed.
Download the browser and it fixes this issue.
Using an old version of chrome driver with the latest Google Chrome locally gave me the same exception.
Just go to the ChromeDriver page and make sure you have the latest version.
I faced similar issue in MacOS. Even after setting binary path in chromeoptions, it didn't work. It got fixed after installing npm i chromedriver
It is also important to download Chrome from the actual website. I ran into the same problem, but I had downloaded Chrome from the Ubuntu software package manager. I uninstalled the package manager version and installed from the website, and the error resolved. Same issue could probably arise installing from other package managers.
Check https://sites.google.com/a/chromium.org/chromedriver/getting-started
You can specify the binary path in the constructor of the webdriver:
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
I did this to solve my problem
private WebDriver driver;
#Before
public void StartBrowser() {
System.setProperty("webdriver.chrome.driver", "C://opt//WebDriver//bin//chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.saucedemo.com/");}
I have solved this problem by installing Google Chrome link and it solved problem automatically (I use Kali Linux) and be sure that it is installed to the "/usr/bin"(default it is downloaded to here).
when i go to command prompt and type chromedriver -v:
ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945#{#614})
but when i try to run this code :
from selenium import webdriver
class InstaBot:
def __init__(self):
self.driver=webdriver.Chrome()
self.driver.get("www.instagram.com")
InstaBot()
it gives me error like this:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
why this is happening i tried to remove selenium as well as chromedriver
and reinstall of version 79.0.3945 but when i run it ,it show this can only be run on version 80
my chrome version is 79.0.3945 which is lastest ,and version 80 chrome is chrome beta
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
...implies that the ChromeDriver v80.0 was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You mentioned about using chromedriver=79.0.3945.36 and the release notes of chromedriver=79.0 clearly mentions the following :
Supports Chrome v79
Presumably you are using chrome v79.0 browser.
So, it's quite evident your have chromedriver=80.0 present within your system which is also within the system PATH variable and is invoked while you:
self.driver=webdriver.Chrome()
Solution
There are two solutions:
Either you upgrade chrome to Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)
Or you can override the default chromedriver v80.0 binary location with chromedriver v79.0 binary location as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
You can find a detailed discussion in Ubuntu: selenium.common.exceptions: session not created: This version of ChromeDriver only supports Chrome version 79
Additional Considerations
Ensure to:
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Reference
You can find a relevant detailed discussion in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
Use Bonigarcia plugin in project. After that it will manage all driver by itself.It reads chrome version and instantiate driver accordingly.
for help follow my post :
https://www.linkedin.com/pulse/webdrivermanager-bonigarcia-rohan-ravi-yadav/
or original git link/post
https://github.com/bonigarcia/webdrivermanager
If any help required , Let me know
UPDATE: This error only happens in Visual Studio 2019. I'm on 16.3.1 Community. Visual Studio 2017 works just fine and causes no issues. So it seems the crux of the issue lies in Visual Studio 2019 for some reason.
NOTE that no matter which IDE I build it in, dotnet run will fail just like VS2019 does. Only if I run the app within VS2017 does it work.
I cross-posted this to Microsoft via Visual Studio's built-in "Report a Problem" menu to attack this issue from multiple angles. I'll report back if/when they do anything (i.e. if they identify it as an issue with Visual Studio).
We've recently upgraded from .NET Framework to .NET Core. The application presently runs on .NET Core 2.2, but the same issues occur on .NET Core 3.0.
We run Selenium for UI testing, and for some reason, Internet Explorer's tests are quite wonky. The driver successfully launches the browser, but the first Navigate() call hangs indefinitely after it successfully performs navigation (never gets beyond that line of code). Here's the full stack trace:
OpenQA.Selenium.WebDriverException
HResult=0x80131500
Message=The HTTP request to the remote WebDriver server for URL http://localhost:52211/session/9e1e828b-5e72-46d8-8012-6b29bfc2d854/url timed out after 10 seconds.
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.set_Url(String value)
at SandboxSelenium.Program.Main(String[] args) in C:\dev_sandbox\SandboxSelenium\SandboxSelenium\Program.cs:line 17
Inner Exception 1: WebException: The operation has timed out.
For simplicity, I created a brand new .NET Core Console App, and did nothing in Main except repeat the above step, and I recreated the issue.
Here are the whole csproj of the console app project, including package references:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
<PackageReference Include="Selenium.WebDriver.IEDriver" Version="3.150.0" />
</ItemGroup>
</Project>
And here's the code I'm calling:
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using System;
using System.IO;
using System.Reflection;
namespace SandboxSelenium
{
public static class Program
{
public static void Main(string[] args)
{
string binPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // In .NET Core you have to tell Selenium where the EXE is.
InternetExplorerOptions opts = new InternetExplorerOptions();
using (var driver = new InternetExplorerDriver(binPath, opts, new TimeSpan(0, 0, 10)))
{
driver.Navigate().GoToUrl("https://example.com/"); // "Line 17" in above error. This line times out!
IWebElement someTextbox = driver.FindElement(By.Id("SomeTextBox")); // Never gets here...
someTextbox.SendKeys("abc123");
}
}
}
}
NOTE: I only set the driver's command timeout to new TimeSpan(0, 0, 10) (10 seconds) in order to shorten the timeout from the default 60 seconds. It times out no matter how long or short the timeout is.
Also, it seems the server executable, IEDriverServer.exe, doesn't close either and is left hanging open after the crash.
I suspect that somehow Selenium is losing track of IE or something, since it seems to completely lose the browser itself. Not sure though. I have tried changing the PageLoadStrategy within InternetExplorerOptions for the driver, but that didn't help any. I have also tried using the 64bit NuGet package for the IE server driver, but that didn't change anything.
Any help is appreciated!
I faced the same issue and managed to solve this by running VS2019 as an administrator, the same worked for command line.
using (var driver = new InternetExplorerDriver(binPath, opts, new
TimeSpan(0, 0, 10)))
The issue is relate to the InternetExplorerDriver setting (the above code). Please check the InternetExplorerDriver Constructor (String, InternetExplorerOptions, TimeSpan) method, we can see that the TimeSpan means the maximum amount of time to wait for each command. if the waiting time is over, it will show this error.
To prevent this error, you could try to extend the waiting time or remove this setting. Code as below:
using (var driver = new InternetExplorerDriver(binPath, opts))
{
driver.Navigate().GoToUrl("https://www.bing.com/"); // "Line 17" in above error. This line times out!
IWebElement someTextbox = driver.FindElement(By.Id("sb_form_q")); // Never gets here...
someTextbox.SendKeys("abc123");
}
Edit:
You could extend the waiting time, such as set it to 20 seconds.
Besides, when we use the SendKeys method to enter values into the textbox, it might be very slow and spend too much time. As a workaround, to decrease the spend time, we could use the IJavaScriptExecutor to execute the JavaScript script, and set the value.
Code as below:
using (var driver = new InternetExplorerDriver(binPath, opts, new TimeSpan(0, 0, 20)))
{
driver.Navigate().GoToUrl("https://www.bing.com/"); // "Line 17" in above error. This line times out!
//IWebElement someTextbox = driver.FindElement(By.Id("sb_form_q")); // Never gets here...
//someTextbox.SendKeys("abc123");
var element = driver.FindElementById("sb_form_q");
var script = "document.getElementById('sb_form_q').value = 'webdriver';";
IJavaScriptExecutor jse = (IJavaScriptExecutor)driver;
jse.ExecuteScript(script, element);
element.SendKeys(Keys.Enter);
}
Alright, it appears you are missing Microsoft Web driver. If you are using Windows OS I recommend go to <settings> --> select Update & Security, then to the left from the list choose For developers and finally click & select Developers mode and wait for the installation to complete and then run your project. I also recommend using EdgeDriver instead of InternetExploperDriver
I hope this helps!
I created an application that use Selenium using .NetCore for use it on Linux, actually this is my code implementation:
public class Program
{
public static async Task Main(string[] args)
{
//Settings for chrome
var chromeOpts = new ChromeOptions();
chromeOpts.AddArgument("headless");
chromeOpts.AddArgument("no-sandbox");
//Get assembly path where chrome driver is located
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
path = Path.GetDirectoryName(path);
var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180));
}
}
as you can see I am using as driver Chrome, I downloaded it here, I also added the driver inside the folder of the assembly, in this way the ChromeDriver knows already where to search it.
On linux I changed the folder permission using chmod -R 777, but when I run my Dotnet application I get this:
Seems that Selenium cannot start the application.
Looking at the Exception I get:
Cannot find Chrome binary
Unfortunately I didn't find anything similar on the web, someone could help me?
Thanks in advance.
UPDATE
I Just reinstalled Chrome on my linux machine and now the error above went away, but there is another problem now, infact I get this error:
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-130-generic x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)\ at ODS.Program.Main(String[] args)
This error message...
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.9 which is pretty ancient.
So there is a clear mismatch between the ChromeDriver version (v2.33) and the recent Chrome Browser version (vVersion 68.0)
Solution
Upgrade ChromeDriver to current ChromeDriver v2.41 level.
Keep Chrome version between Chrome v67-69 levels. (as per ChromeDriver v2.41 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Execute your #Test.
References
You can find a couple of relevant discussions in:
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium on debian server
Message: unknown error: Chrome failed to start: exited abnormally on AWS Cloud9 with Linux 4.9.85-38.58.amzn1.x86_64 x86_64
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally with ChromeDriver Chrome and Selenium through Python on VPS
first, check your google-chrome version
then download related chromedriver version i.e
I have an automation project using Selenium WebDriver in version 3.6 and the Chrome Driver. The software was working fine until it started to display the error
Unhandled exception has occurred in your application. If you click
Continue, the application will ignore this error and attempt to
continue. If you click Quit, the application will close immediately.
unknown error: Element is not clickable at point (25, -9) (Session
info: chrome=61.0.3163.100) (Driver info: chromedriver=2.31.488763
(092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT
6.1.7601 SP1 x86_64).
I'm using the .click () method to click on the element, and this always worked, I've never had any problems with the software running for months
Searching the internet I found methods that even worked like using .SendKey () and IJavaScriptExecutor to give a scroll to the element. But the point is I never had to do this ..
Could it be some bug in this version of Selenium? Maybe Chrome Driver?
This is caused by having Chrome version 61+ and not using the latest ChromeDriver.
Download the latest ChromeDriver (2.3.2) which "Fixes a bug where Chromedriver fails to click due to page scrolling changes in Chrome 61+".