I am trying to launch chrome with an URL, the browser launches and it does nothing after that.
I am seeing the below error after 1 minute:
Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
My configuration:
Chrome : 66
ChromeBrowser : 2.39.56
P.S everything works fine in Firefox
Thumb rule
A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
This error message...
org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your code trials and the versioning information of all the binaries would have given us some hint about what's going wrong.
However as per Add --disable-dev-shm-usage to default launch flags seems adding the argument --disable-dev-shm-usage will temporary solve the issue.
If you desire to initiate/span a new Chrome Browser session you can use the following solution:
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized"); // open Browser in maximized mode
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
WebDriver driver = new ChromeDriver(options);
driver.get("https://google.com");
disable-dev-shm-usage
As per base_switches.cc disable-dev-shm-usage seems to be valid only on Linux OS:
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// The /dev/shm partition is too small in certain VM environments, causing
// Chrome to fail or crash (see http://crbug.com/715363). Use this flag to
// work-around this issue (a temporary directory will always be used to create
// anonymous shared memory files).
const char kDisableDevShmUsage[] = "disable-dev-shm-usage";
#endif
In the discussion Add an option to use /tmp instead of /dev/shm David mentions:
I think it would depend on how are /dev/shm and /tmp mounted.
If they are both mounted as tmpfs I'm assuming there won't be any difference.
if for some reason /tmp is not mapped as tmpfs (and I think is mapped as tmpfs by default by systemd), chrome shared memory management always maps files into memory when creating an anonymous shared files, so even in that case shouldn't be much difference. I guess you could force telemetry tests with the flag enabled and see how it goes.
As for why not use by default, it was a pushed back by the shared memory team, I guess it makes sense it should be useing /dev/shm for shared memory by default.
Ultimately all this should be moving to use memfd_create, but I don't think that's going to happen any time soon, since it will require refactoring Chrome memory management significantly.
Reference
You can find a couple of detailed discussions in:
unknown error: DevToolsActivePort file doesn't exist error while executing Selenium UI test cases on ubuntu
Tests fail immediately with unknown error: DevToolsActivePort file doesn't exist when running Selenium grid through systemd
Outro
Here is the link to the Sandbox story.
I started seeing this problem on Monday 2018-06-04. Our tests run each weekday. It appears that the only thing that changed was the google-chrome version (which had been updated to current) JVM and Selenium were recent versions on Linux box ( Java 1.8.0_151, selenium 3.12.0, google-chrome 67.0.3396.62, and xvfb-run).
Specifically adding the arguments "--no-sandbox" and "--disable-dev-shm-usage" stopped the error.
I'll look into these issues to find more info about the effect, and other questions as in what triggered google-chrome to update.
ChromeOptions options = new ChromeOptions();
...
options.addArguments("--no-sandbox");
options.addArguments("--disable-dev-shm-usage");
We were having the same issues on our jenkins slaves (linux machine) and tried all the options above.
The only thing helped is setting the argument
chrome_options.add_argument('--headless')
But when we investigated further, noticed that XVFB screen doesn't started property and thats causing this error. After we fix XVFB screen, it resolved the issue.
I had the same problem in python. The above helped. Here is what I used in python -
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('/path/to/your_chrome_driver_dir/chromedriver',chrome_options=chrome_options)
I was facing the same issue recently and after some trial and error it worked for me as well.
MUST BE ON TOP:
options.addArguments("--no-sandbox"); //has to be the very first option
BaseSeleniumTests.java
public abstract class BaseSeleniumTests {
private static final String CHROMEDRIVER_EXE = "chromedriver.exe";
private static final String IEDRIVER_EXE = "IEDriverServer.exe";
private static final String FFDRIVER_EXE = "geckodriver.exe";
protected WebDriver driver;
#Before
public void setUp() {
loadChromeDriver();
}
#After
public void tearDown() {
if (driver != null) {
driver.close();
driver.quit();
}
}
private void loadChromeDriver() {
ClassLoader classLoader = getClass().getClassLoader();
String filePath = classLoader.getResource(CHROMEDRIVER_EXE).getFile();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeDriverService service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File(filePath))
.build();
ChromeOptions options = new ChromeOptions();
options.addArguments("--no-sandbox"); // Bypass OS security model, MUST BE THE VERY FIRST OPTION
options.addArguments("--headless");
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("start-maximized"); // open Browser in maximized mode
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.merge(capabilities);
this.driver = new ChromeDriver(service, options);
}
}
GoogleSearchPageTraditionalSeleniumTests.java
#RunWith(SpringRunner.class)
#SpringBootTest
public class GoogleSearchPageTraditionalSeleniumTests extends BaseSeleniumTests {
#Test
public void getSearchPage() {
this.driver.get("https://www.google.com");
WebElement element = this.driver.findElement(By.name("q"));
assertNotNull(element);
}
}
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
In my case in the following environment:
Windows 10
Python 3.7.5
Google Chrome version 80 and corresponding ChromeDriver in the path C:\Windows
selenium 3.141.0
I needed to add the arguments --no-sandbox and --remote-debugging-port=9222 to the ChromeOptions object and run the code as administrator user by lunching the Powershell/cmd as administrator.
Here is the related piece of code:
options = webdriver.ChromeOptions()
options.add_argument('headless')
options.add_argument('--disable-infobars')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--no-sandbox')
options.add_argument('--remote-debugging-port=9222')
driver = webdriver.Chrome(options=options)
I ran into this problem on Ubuntu 20 with Python Selenium after first downloading the chromedriver separately and then using sudo apt install chromium-browser Even though they were the same version this kept happening.
My fix was to use the provided chrome driver that came with the repo package located at
/snap/bin/chromium.chromedriver
driver = webdriver.Chrome(chrome_options=options, executable_path='/snap/bin/chromium.chromedriver')
Update:
I am able to get through the issue and now I am able to access the chrome with desired url.
Results of trying the provided solutions:
I tried all the settings as provided above but I was unable to resolve the issue
Explanation regarding the issue:
As per my observation DevToolsActivePort file doesn't exist is caused when chrome is unable to find its reference in scoped_dirXXXXX folder.
Steps taken to solve the issue
I have killed all the chrome processes and chrome driver processes.
Added the below code to invoke the chrome
System.setProperty("webdriver.chrome.driver","pathto\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
WebDriver driver = new ChromeDriver(options);
driver.get(url);
Using the above steps I was able to resolve the issue.
Thanks for your answers.
In my case it was problem with CI Agent account on ubuntu server, I solved this using custom --user-data-dir
chrome_options.add_argument('--user-data-dir=~/.config/google-chrome')
My account used by CI Agent didn't have necessary permissions, what was interesting everything was working on root account
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--profile-directory=Default')
chrome_options.add_argument('--user-data-dir=~/.config/google-chrome')
driver = webdriver.Chrome(options=chrome_options)
url = 'https://www.google.com'
driver.get(url)
get_url = driver.current_url
print(get_url)
There is lot of possible reasons for the RESPONSE InitSession ERROR unknown error: DevToolsActivePort file doesn't exist error message (as we can see from the number of answers for this question). So let's dive deeper to explain what exactly this error message means.
According to chromedriver source code the message is created in ParseDevToolsActivePortFile method. This method is called from the loop after launching chrome process.
In the loop the driver check if the chrome process is still running and if the ParseDevToolsActivePortFile file was already created by chrome. There is a hardcoded 60s timeout for this loop.
I see two possible reasons for this message:
Chrome is really slow during startup - for example due to lack of system resources - mainly CPU or memory. In this case it can happen that sometimes chrome manage to start in time limit and sometimes not.
There is another issue which prevents chrome to start - missing or broken dependency, wrong configuration etc. In such case this error message is not really helpful and you should find another log message which explain the true reason of the failure.
It happens when chromedriver fails to figure out what debugging port chrome is using.
One possible cause is an open defect with HKEY_CURRENT_USER\Software\Policies\Google\Chrome\UserDataDir
But in my last case, it was some other unidentified cause.
Fortunately setting port number manually worked:
final String[] args = { "--remote-debugging-port=9222" };
options.addArguments(args);
WebDriver driver = new ChromeDriver(options);
As stated in this other answer:
This error message... implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Among the possible causes, I would like to mention the fact that, in case you are running an headless Chromium via Xvfb, you might need to export the DISPLAY variable: in my case, I had in place (as recommended) the --disable-dev-shm-usage and --no-sandbox options, everything was running fine, but in a new installation running the latest (at the time of writing) Ubuntu 18.04 this error started to occurr, and the only possible fix was to execute an export DISPLAY=":20" (having previously started Xvfb with Xvfb :20&).
You can get this error simply for passing bad arguments to Chrome. For example, if I pass "headless" as an arg to the C# ChromeDriver, it fires up great. If I make a mistake and use the wrong syntax, "--headless", I get the DevToolsActivePort file doesn't exist error.
I was stuck on this for a very long time and finally fixed it by adding this an additional option:
options.addArguments("--crash-dumps-dir=/tmp")
I know it's an old question and it already has a lot of answers. However, I ran into this issue, bumped into this thread and none of the proposed solutions helped. After spending a few days(!) on it I finally found a solution:
My problem was that I was using the selenium/standalone-chrome image on a MacBook with M1 chip. After switching to seleniarm/standalone-chromium everything finally started to work.
I had the same issue, but in my case chrome previously was installed in user temp folder, after that was reinstalled to Program files. So any of solution provided here was not help me. But if provide path to chrome.exe all works:
chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
I hope this helps someone =)
In my case it happened when I've tried to use my default user profile:
...
options.addArguments("user-data-dir=D:\\MyHomeDirectory\\Google\\Chrome\\User Data");
...
This triggered chrome to reuse processes already running in background, in such a way, that process started by chromedriver.exe was simply ended.
Resolution: kill all chrome.exe processes running in background.
update capabilities in conf.js as
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['todo-spec.js'],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage']
}
},
};
Old question but a similar issue nearly drove me to insanity so sharing my solution. None of the other suggestions fixed my issue.
When I updated my Docker image Chrome installation from an old version to Chrome 86, I got this error. My setup was not identical but we were instantiating Chrome through a selenium webdriver.
The solution was to pass the options as goog:chromeOptions hash instead of chromeOptions hash. I truly don't know if this was a Selenium, Chrome, Chromedriver, or some other update, but maybe some poor soul will find solace in this answer in the future.
For Ubuntu 20 it did help me to use my systems chromium driver instead of the downloaded one:
# chromium which
/snap/bin/chromium
driver = webdriver.Chrome('/snap/bin/chromium.chromedriver',
options=chrome_options)
And for the downloaded webdriver looks like it needs the remote debug port --remote-debugging-port=9222 to be set, as in one of the answers (by Soheil Pourbafrani):
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--remote-debugging-port=9222")
driver = webdriver.Chrome('<path_to>/chromedriver', options=chrome_options)
Date 9/16/2021
Everything works fine running chrome with selenium locally with python inside the docker hosted ubuntu container. When attempting to run from Jenkins the error above is returned WebDriverException: unknown error: DevToolsActivePort
Environment:
-Ubuntu21.04 inside a docker container with RDP access.
-chromedriver for chrome version: 93
Solution:
Inside the python file that starts the browser I had to set the DISPLAY environment variable using the following lines:
import os
os.environ['DISPLAY'] = ':10.0'
#DISPLAY_VAR = os.environ.get('DISPLAY')
#print("DISPLAY_VAR:", DISPLAY_VAR)
In my case, I was trying to create a runnable jar on Windows OS with chrome browser and want to run the same on headless mode in unix box with CentOs on it. And I was pointing my binary to a driver that I have downloaded and packaged with my suite. For me, this issue continue to occur irrespective of adding the below:
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--no-sandbox");
System.setProperty("webdriver.chrome.args", "--disable-logging");
System.setProperty("webdriver.chrome.silentOutput", "true");
options.setBinary("/pointing/downloaded/driver/path/in/automationsuite");
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-gpu"); // applicable to windows os only
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("window-size=1024,768"); // Bypass OS security model
options.addArguments("--log-level=3"); // set log level
options.addArguments("--silent");//
options.setCapability("chrome.verbose", false); //disable logging
driver = new ChromeDriver(options);
Solution that I've tried and worked for me is, download the chrome and its tools on the host VM/Unix box, install and point the binary to this in the automation suite and bingo! It works :)
Download command:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
Install command:
sudo yum install -y ./google-chrome-stable_current_*.rpm
Update suite with below binary path of google-chrome:
options.setBinary("/opt/google/chrome/google-chrome");
And.. it works!
I also faced this issue while integrating with jenkins server, I was used the root user for jenkin job, the issue was fixed when I changed the user to other user. I am not sure why this error occurs for the root user.
Google Chrome Version 71.0
ChromeDriver Version 2.45
CentOS7 Version 1.153
I run selenium tests with Jenkins running on an Ubuntu 18 LTS linux. I had this error until I added the argument 'headless' like this (and some other arguments):
ChromeOptions options = new ChromeOptions();
options.addArguments("headless"); // headless -> no browser window. needed for jenkins
options.addArguments("disable-infobars"); // disabling infobars
options.addArguments("--disable-extensions"); // disabling extensions
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
ChromeDriver driver = new ChromeDriver(options);
driver.get("www.google.com");
Had the same issue. I am running the selenium script on Google cloud VM.
options.addArguments("--headless");
The above line resolved my issue. I removed the other optional arguments. I think the rest lines of code mentioned in other answers did not have any effect on resolving the issue on the cloud VM.
in my case, when i changed the google-chrome and chromedriver version, the error was fixed :)
#google-chrome version
[root#localhost ~]# /usr/bin/google-chrome --version
Google Chrome 83.0.4103.106
#chromedriver version
[root#localhost ~]# /usr/local/bin/chromedriver -v
ChromeDriver 83.0.4103.14 (be04594a2b8411758b860104bc0a1033417178be-refs/branch-heads/4103#{#119})
ps: selenium verison was 3.9.1
No solution worked for my. But here is a workaround:
maxcounter=5
for counter in range(maxcounter):
try:
driver = webdriver.Chrome(chrome_options=options,
service_log_path=logfile,
service_args=["--verbose", "--log-path=%s" % logfile])
break
except WebDriverException as e:
print("RETRYING INITIALIZATION OF WEBDRIVER! Error: %s" % str(e))
time.sleep(10)
if counter==maxcounter-1:
raise WebDriverException("Maximum number of selenium-firefox-webdriver-retries exceeded.")
It seems there are many possible causes for this error. In our case, the error happened because we had the following two lines in code:
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
chromeOptions.setBinary(chromeDriverPath);
It's solved by removing the second line.
I ran into same issue, i am using UBUNTU, PYTHON and OPERA browser. in my case the problem was originated because i had an outdated version of operadriver.
Solution:
1. Make sure you install latest opera browser version ( do not use opera beta or opera developer), for that go to the official opera site and download from there the latest opera_stable version.
Install latest opera driver (if you already have an opera driver install, you have to remove it first use sudo rm ...)
wget https://github.com/operasoftware/operachromiumdriver/releases/download/v.80.0.3987.100/operadriver_linux64.zip
unzip operadriver_linux64.zip
sudo mv operadriver /usr/bin/operadriver
sudo chown root:root /usr/bin/operadriver
sudo chmod +x /usr/bin/operadriver
in my case latest was 80.0.3987 as you can see
Additionally i also installed chromedriver (but since i did it before testing, i do not know of this is needed) in order to install chromedriver, follow the steps on previous step :v
Enjoy and thank me!
Sample selenium code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Opera()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.quit()
I came across the same problem, in my case there are two different common user userA and userB in Linux system.
userA first run the selinium programe which start chrome browswer with ChromeDriver successfully, when it came to userB, the DevToolsActivePort file doesn't exist error occur.
I tried the --remote-debugging-port=9222 option, but it lead to a new exception:
selenium.common.exceptions.WebDriverException: Message: chrome not reachable
The I ran google-chome directory and see the following error:
mkdir /tmp/Crashpad/new: Permission denied (13)
The I search the problem and got this:
https://johncylee.github.io/2022/05/14/chrome-headless-%E6%A8%A1%E5%BC%8F%E4%B8%8B-devtoolsactiveport-file-doesn-t-exist-%E5%95%8F%E9%A1%8C/
chrome_options.add_argument(f"--crash-dumps-dir={os.path.expanduser('~/tmp/Crashpad')}")
Thanks to #johncylee.
Hi i m trying to setup selenium with eclipse on a Mac pc.
When I download the ChromeDriver and place it on the below folder :
System.setProperty("webdriver.chrome.driver","/Users/george/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
I run the code.
Then I get the following exception :
Starting ChromeDriver 2.21.371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 33424 Only local
connections are allowed. Exception in thread "main"
org.openqa.selenium.WebDriverException: unknown error: cannot find
Chrome binary (Driver info: chromedriver=2.21.371459
(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.10.5
x86_64) (WARNING: The server did not provide any stacktrace
information) Command duration or timeout: 312 milliseconds Build info:
version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'Georges-Mac-mini.local', ip: '192.168.1.2',
os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5',
java.version: '1.7.0_25' Driver info:
org.openqa.selenium.chrome.ChromeDriver
So I m assuming that some binary is missing? Note that I use regularly Chrome as my browser.. I dont know if this is related or not.
My pc is mac. I have read the ChromeDriver site but I dont understand what exactly to do. I have problems navigating to paths that are a bit strange like : "Google Drive" instead of "Google/Drive" or paths like
"cd Chrome\ Apps.localized/" or "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome". I mean , wt?? are those back and forth slashes ??? I just now a few things on linux but here.. i m stuck and confused
On Windows things where much easier.. you just downloaded an .exe file locally point the driver with options to that file and everything was smoothly. I cant find information on mac specific.
Can anyone help ?
Thanks
"cannot find Chrome binary" simply means the os cannot find chrome app. Just check chrome installation directory. Right directory should be "/Applications/Google Chrome.app". If you download your chrome from third platform, the directory may be "/Applications/Chrome.app". It makes the os cannot find your chrome.
The stack trace indicates that it cannot find the binary for the chrome webdrive. You'll need to download it if you haven't already. Once you have downloaded the chrome webdriver, point your application at the binary.
if you have a path with spaces, such as
/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
you'll need to escape the spaces with backslashes like so
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
a backslash followed by a space, \, tells the argument parser not to use that space as a delimiter but rather to include it as part of the path.
Aside from trying the path with and without slashes (the ruby driver expects spaces not be escaped), this problem may also be caused by a version mismatch between Chrome and Chromedriver.
Chrome Canary, specifically, is often unsupported by the current stable Chromedriver release. There are nightly builds linked at https://sites.google.com/a/chromium.org/chromedriver/chromedriver-canary. Enter the proper prefix in the search box for the Mac version, then scroll as far as it goes for the most recent version–yeah, the interface sucks.
There's a decent chance this won't work, either. Installing the stable Chrome release is your best bet.
I was facing this "cannot find Chrome binary", when I realised that I don't have the Chrome Browser installed before to try to use it.
Don't do this at home, guys...
I found that upgrading selenium-webdriver to 3.142.3 and Capybara to 3.20.2 fixed this for me. This required making some changes to my webdriver configuration:
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions': {
args: %w(--disable-gpu --headless --no-sandbox --window-size=1024,768)
}
)
driver = Capybara::Selenium::Driver.new app, {
browser: :chrome,
desired_capabilities: capabilities,
http_client: client,
}
Use double slashes in your path like this:
//Test Data//Drivers//chromedriver
and copy and paste the chrome driver exe to some other location.
I have an automation framework developed around Selenium-WebDriver which launches Chrome and navigates to specified URL and performs specified automation.
When I commissioned the framework to perform a long task and left it overnight to run (Run was not successful). The following day when I tried to re-run a new set of Tests, Selenium was able to fire Chrome but the Browser would not navigate to the specified URL. The following is the detailed stack trace.
Starting ChromeDriver (v2.7.236900) on port 60678
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=41.0.2272.118)
(Driver info: chromedriver=2.7.236900,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 10.12 seconds
Build info: version: '2.24.1', revision: '17205', time: '2012-06-19 16:53:24'
System info: os.name: 'Windows 8.1', os.arch: 'x86', os.version: '6.3', java.version: '1.8.0_25'
Driver info: driver.version: RemoteWebDriver
Session ID: a2fafed66d51994e3ef57bada99fddbf
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:472)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:683)
at com.gravitant.utils.Util.launchBrowser(Util.java:1711)
at com.gravitant.test.RunTests.start(RunTests.java:147)
at com.gravitant.test.RunTests.main(RunTests.java:80)
This is the second time I am facing the same issue.
When I tried to google search the error I was able find this particular forum.
I tried to re-download Chrome_driver but it did not help. Restarting the system did not help either. I double checked the code and all the set-up but nothing was changed.
Curiously I was able to stumble upon a curious solution.
Solution - Re-installing Chrome Browser solved the issue. I was able to run the tests perfectly.
I am curious to understand why this was and what might have caused chrome to behave so oddly.
In my case, the chrome browser version and chromedriver versions were incompatible. Chrome updated automatically from 56 to 57 and my chromedriver version was 2.27.
The 2 issues throwing 'org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension' error (when maximizing the browser and when taking screenshots), where fixed after updating to cromdriver version 2.28.
The issue here is, Selenium-WebDriver is unable to launch the installed 3rd Party Extensions in chrome.
I encountered the issue today as well, so instead of re-installing google chrome, I deleted all the extensions I had installed on Chrome. I have a couple of "Add Blocker" extensions installed.
Reason for the exception is chrome failed to load selenium automation extension.
When ever selenium opens chrome browser, selenium loads a chrome extension in chrome browser to work with it from some temp location. If chrome browser failed to load that extension it will throw an exception.
I got the same exception when my organization blocked loading third party extensions in my chrome browser.
Test method
Veolia.BrentGWP.UserStories.Features.BrentGWPFeature._3_EnterDetailsAndSelectAnAddress_John threw exception:
System.InvalidOperationException: unknown error: cannot get automation extension
from unknown error: page could not be found: chrome- extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
(Session info: chrome=41.0.2272.118)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)
I am using Selenium with C# and Visual Studio.
I was facing the same issue, In my case the main problem was:
Incompatibility between chrome version and chromedriver version.
Chrome browser is self upgraded, it updates to latest version automatically (In most of case).
So you need to upgrade chromedriver version periodically and there are release notes are also available which describes the compability between chromedriver and chrome version.
I had this on my Windows 10 (64 bit) PC after upgrading to Selenium 3.3.1. Downloading Chromedriver 2.29 and overwriting the old version worked. See - https://chromedriver.storage.googleapis.com/index.html?path=2.29/
In case someone is still looking for an answer. Here is the matching response for my situation.
https://github.com/SeleniumHQ/selenium/issues/3508
This exactly what is happening in my case where, I'm getting it 60-70% of the time when maximize is called
org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:945)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWindow.maximize(EventFiringWebDriver.java:644)
at org.openqa.selenium.remote.server.handler.MaximizeWindow.call(MaximizeWindow.java:30)
at org.openqa.selenium.remote.server.handler.MaximizeWindow.call(MaximizeWindow.java:1)
I found this problem is chromedriver version cause. My case run ok when i update the chromedriver.
I am trying to use Selenium Grid with Jenkins.
When I start Selenium Hub and Node with the server-standalone 2.35.0 jar, everything works perfect.
However, does not work when I use the Jenkins Selenium Grid Plugin as hub.
The Error appears here:
driver = new RemoteWebDriver ( new URL ( gridURL ), capabilities );
grid URL is "http://localhost:4444/wd/hub"
capabilities is this:
DesiredCapabilities capabilities = DesiredCapabilities.firefox ();
capabilities.setPlatform ( Platform.LINUX );
This exception is thrown:
org.openqa.selenium.WebDriverException: Error forwarding the new session new session request for webdriver should contain a location header with the session.
Command duration or timeout: 25.28 seconds
Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-31-generic', java.version: '1.7.0_40'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
As Hub I use the Jenkins Selenium Plugin Version 2.3
As Node I use selenium-server-standalone-2.35.0.jar.
When I open http://localhost:4444/ with a browser, it says: You are using grid 2.29.0
So I downloaded selenium-server-standalone-2.29.0.jar and let it run as a hub. The node still is Version 2.35.0.
Then I've got the same exception. I tried node and hub with 2.29.0 but it seems that my Firefox is too new for this.
I searched several hours but didn't find anything regarding this error.
Edit:
The Plugin, which is installed by Jenkins, is from August, 18th 2013: https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin
The developer updated the plugin two days later on August, 20th 2013: https://github.com/jenkinsci/selenium-plugin/commit/316eccdef608e855863cf04b1c240fa2c7b8b762
I don't know if this is causing my errors, but it is possible. I don't know yet how to do this, but I'm going to try to build my own plugin version from the source code on github.
I now know definitely what the problem is:
As I mentioned above the node is Selenium Version 2.35. The current Jenkins Selenium Plugin is Version 2.3 which uses Selenium 2.29. This is causing the error.
Now I used Selenium Version 2.29 as node. And installed Firefox Version 18. Now everything is working fine. I contacted the developer and I am trying to build the current Plugin Version from git. For now without success, but I think I'll open another thread for this.
Thank you for your help.
You can update the selenium version in the jenkins plugin, replace 2.29.0 with 2.39.0 in the below mentioned path:
[JenkinsFolder]\plugins\selenium\WEB-INF\lib
You will find the old jar here. replace it with the latest jar.
It will work fine.
This error means that you have no nodes connected to the hub. The Hub is UP and receiving connections, but is unable to forward the request to a node.
Make sure that you have nodes connected to your hub. You can do this by --
java -jar selenium-server-2.29.0.jar -role node -hubUrl http://ip-of-hub:4444/wd/register
This command may be inaccurate. Consult the official doc.
I'm trying to use Chrome Drive to execute some of my tests, which are working perfectly with Firefox, but I'm not being able to execute them, I'm already verified the requirements, which are the location of Chrome, Version 12 or higher, and things like that, but anyway still not working correctly, the way to call the driver is:
WebDriver fd = new ChromeDriver();
fd.get("url");
and then searching some elements, but nothing is working, the error message is:
Exception in thread "main"
org.openqa.selenium.WebDriverException:
Couldn't locate Chrome. Set
webdriver.chrome.bin System info:
os.name: 'Windows XP', os.arch: 'x86',
os.version: '5.1', java.version:
'1.6.0_18' Driver info:
driver.version: ChromeDriver at
org.openqa.selenium.chrome.ChromeBinary.getChromeBinaryLocation(ChromeBinary.java:220)
at
org.openqa.selenium.chrome.ChromeBinary.getCommandline(ChromeBinary.java:121)
at
org.openqa.selenium.chrome.ChromeBinary.prepareProcess(ChromeBinary.java:67)
at
org.openqa.selenium.chrome.ChromeBinary.start(ChromeBinary.java:109)
at
org.openqa.selenium.chrome.ChromeCommandExecutor.start(ChromeCommandExecutor.java:373)
at
org.openqa.selenium.chrome.ChromeDriver.startClient(ChromeDriver.java:65)
at
org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:85)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:25)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:43)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:53)
at
equifax.qa.test.NewTests.access.main(access.java:11)
Please if anyone can help me would be great.
I was able to get this to work by launching the selenium server like this:
java -jar selenium-server-standalone-2.0rc2.jar -Dwebdriver.chrome.driver=c:\path\to\chromedriver.exe
(Running Windows 7 64bit, Chrome 12, selenium server rc2)
Download the ChromeDriver.exe from http://code.google.com/p/selenium/downloads/list then add the system property like so:
System.setProperty("webdriver.chrome.driver", "...\chromedriver.exe");
Use this for Chrome
Step-1 Download Chrome driver from location
Step-2 Use Testng Framework
#BeforeClass
public void setUp() throws Exception
{
System.setProperty("webdriver.chrome.driver", "D://Work-Selenium//chromedriver_win32//chromedriver.exe");
driver = new ChromeDriver();
baseUrl = "http://google.com";
driver.get(baseUrl);
}
Just download the chromedriver_win32_13.0.775.0.zip and selenium-server-standalone-2.0rc3.jar from [http://code.google.com/p/selenium/downloads/list][1]
Unzip the chromedriver_win32_13.0.775.0.zip into a folder, Eg. C:/drivers/chrome/, so that the chromedriver.exe is located at C:/drivers/chrome/chromedriver.exe.
Register the node against the hub on port 6668 (for example)
java -jar selenium-server-standalone-2.0rc3.jar -role webdriver -hub http://hubUrlHostname:4444/grid/register -port 6668 -browser "browserName=chrome,version=13.0,platform=windows" -Dwebdriver.chrome.driver=C:\drivers\chrome\chromedriver.exe
If you access to
http://hubUrlHostname:4444/grid/console
you should see the Chrome driver registered.
Have you made sure that you have downloaded the Chrome driver from http://code.google.com/p/selenium/downloads/list and placed it in your PATH?
have a look at http://code.google.com/p/selenium/wiki/ChromeDriver for more details
You can set the capabilities to point to the binary of the browser to be launched.
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.binary", "/usr/lib/chromium-browser/chromium-browser");
WebDriver driver = new ChromeDriver(capabilities);
For ex:- Chromium Browser(33.0.1729.0 )works fine with ChromeDriver 2.7 and not the with the older ones.
You can choose from all the chromedriver version available from the link below:- http://chromedriver.storage.googleapis.com/index.html
So try to use the browser version supported by the chromedriver.
If you are using Maven Project. Follow the below steps
Download the latest chromedriver.exe from this link.
Create a drivers folder in test. It should look like this src/test/resources/drivers
Move the chromedriver.exe to the above path in step 2
Use the below code for before creating chrome driver object
System.setProperty("webdriver.chrome.driver",
Thread.currentThread().getContextClassLoader().getResource("drivers/chromedriver.exe").getFile());