Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When running WebDriver with Chrome browser, getting message, "Only local connections are allowed" even though browser launches properly

When I run Chrome browser using WebDriver, I am getting following message on console. Please let me know how to resolve it.

"Starting ChromeDriver (v2.10.267521) on port 22582 " "Only local connections are allowed."

Here is my sample code:

public class Browserlaunch {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32   \\chromedriver.exe");
        WebDriver driver = new ChromeDriver() ;
        driver.get("http://webdunia.com");
        driver.close();
        driver.quit();
    }
}
like image 787
user3899403 Avatar asked Aug 01 '14 12:08

user3899403


People also ask

Does Selenium WebDriver work with Chrome?

Through WebDriver, Selenium supports all major browsers on the market such as Chrome/Chromium, Firefox, Internet Explorer, Edge, Opera, and Safari.


4 Answers

This is an informational message only. What the message is telling you is that the chromedriver executable will only accept connections from the local machine.

Most driver implementations (the Chrome driver and the IE driver for sure) create a HTTP server. The language bindings (Java, Python, Ruby, .NET, etc.) all use a JSON-over-HTTP protocol to communicate with the driver and automate the browser. Since the HTTP server is simply listening on an open port for HTTP requests generated by the language bindings, connections to the HTTP server started by the language bindings are only allowed to come from other processes on the same host. Note carefully that this limitation does not apply to connections the browser can make to outside websites; rather it simply prevents incoming connections from other websites.

like image 196
JimEvans Avatar answered Oct 13 '22 10:10

JimEvans


Not necessarily the best practice, but my environment was a local network with several machines which needed access to the selenium.

When running the chromedriver, you can pass through a param like so :

chromedriver --whitelisted-ips=""

This will basically whitelist all IP's, not always an ideal solution of course and be careful with it for production enviornments, but you should be presented with a verbose warning :

Starting ChromeDriver 2.16.333244 (15fb740a49ab3660b8f8d496cfab2e4d37c7e6ca) on port 9515 All remote connections are allowed. Use a whitelist instead!

A work-around at best, but it works.

Relative check-in

like image 38
Pogrindis Avatar answered Oct 13 '22 09:10

Pogrindis


I was getting the exact same errors. I battled this issue for a few hours today. It seemed to be caused by a mismatch between the versions of chromedriver and selenium-server-standalone. The config.js file was referencing a directory that had chromedriver 2.9 and selenium-server-standalone 2.35.0. Once I made sure we were referencing 2.10 and 2.42.2, it worked.

like image 15
newToSeleniumMate Avatar answered Oct 13 '22 10:10

newToSeleniumMate


Chromedriver is a WebDriver. WebDriver is an open-source tool for automated testing of web apps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. When you run this driver, it will enable your scripts to access this and run commands on Google Chrome.

This can be done via scripts running in the local network (Only local connections are allowed.) or via scripts running on outside networks (All remote connections are allowed.). It is always safer to use the Local Connection option. By default your Chromedriver is accessible via port 9515.

To answer the question, it is just an informational message. You don't have to worry about it.

Given below are both options.

$ chromedriver

Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

This is by whitelisting all IPs.

$ chromedriver --whitelisted-ips=""

Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 9515
All remote connections are allowed. Use a whitelist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
like image 6
Keet Sugathadasa Avatar answered Oct 13 '22 09:10

Keet Sugathadasa