When running WebDriver with Chrome browser, gettin

2019-01-03 10:28发布

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();
    }
}

8条回答
闹够了就滚
2楼-- · 2019-01-03 10:46

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-03 10:51

This is an informational message only. It means nothing if your test scripts and chromedriver are on the same machine then it is possible to add the "whitelisted-ips" option .your test will run fine.However if you use chromedriver in a grid setup, this message will not appear

查看更多
老娘就宠你
4楼-- · 2019-01-03 10:52

I solved this error by installing the browser driver:

  1. Navigate your browser to seleniumhq.org website
  2. Select the Downloads tab
  3. Scroll down the page to the Browser section and download the driver you want by clicking the link, for example, Google Chrome Driver
  4. Double-click the downloaded file, for example, chromedriver_mac64(1).zip
  5. Double-click the extracted file, for example, chromedriver

Reference: search YouTube.com for the error

Platform: macOS High Sierra 10.13.3

查看更多
趁早两清
5楼-- · 2019-01-03 10:58

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.

查看更多
混吃等死
6楼-- · 2019-01-03 11:02

Very often this error appears if you use incompatible versions of Selenium and ChromeDriver.

Selenium 3.0.1 for Maven project:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.1</version>
    </dependency>

ChromeDriver 2.27: https://sites.google.com/a/chromium.org/chromedriver/downloads

查看更多
太酷不给撩
7楼-- · 2019-01-03 11:04

I had to run my commands in the one and same terminal, not seperately.

nohup sudo Xvfb :10 -ac
export DISPLAY=:10
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalone.jar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver"
查看更多
登录 后发表回答