Only local connections are allowed Chrome and Selenium webdriver

前端 未结 12 1670
误落风尘
误落风尘 2020-11-30 05:59

I am using Chrome webdriver 2.23 & Selenium 2.53.1. I have tried a lot, but could not get it fixed. Whenever I run my selenium script, it is giving me the following err

相关标签:
12条回答
  • 2020-11-30 06:17

    You need to pass --whitelisted-ips= into chrome driver (not chrome!). If you use ChromeDriver locally/directly (not using RemoteWebDriver) from code, it shouldn't be your problem.

    If you use it remotely (eg. selenium hub/grid) you need to set system property when node starts, like in command:

    java -Dwebdriver.chrome.whitelistedIps= testClass etc...
    

    or docker by passing JAVA_OPTS env

      chrome:
        image: selenium/node-chrome:3.141.59
        container_name: chrome
        depends_on:
          - selenium-hub
        environment:
          - HUB_HOST=selenium-hub
          - HUB_PORT=4444
          - JAVA_OPTS=-Dwebdriver.chrome.whitelistedIps=
    
    0 讨论(0)
  • 2020-11-30 06:19

    I followed my frnd suggestion and it worked like a gem for me:

    Working Code:

    1) Downloaded chromedriver.

    2) Code is

    import org.openqa.selenium.WebDriver;
    
    import org.openqa.selenium.chrome.ChromeDriver;
    
    public class Sel {
      public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\Downloads\\chromedriver_win32\\chromedriver.exe"); // path of chromedriver 
        WebDriver driver = new ChromeDriver();
    
          driver.get("https://google.ca");
          driver.manage().window().maximize();
          driver.getTitle();
    
      }
    }
    
    0 讨论(0)
  • 2020-11-30 06:23

    C#:

        ChromeOptions options = new ChromeOptions();
    
        options.AddArgument("C:/Users/username/Documents/Visual Studio 2012/Projects/Interaris.Test/Interaris.Tes/bin/Debug/chromedriver.exe");
    
        ChromeDriver chrome = new ChromeDriver(options);
    

    Worked for me.

    0 讨论(0)
  • 2020-11-30 06:24

    Here you are a working stack:

    Some previous notes:

    • If you run selenium in a non graphical enviromnent, xvfb is required.

    • You will need selenium-server-standalone-2.53.1.jar (working version). You can download selenium versions here: http://selenium-release.storage.googleapis.com/index.html

    • You will also need chromedriver v 2.27. Download link: https://chromedriver.storage.googleapis.com/index.html

    1) Run sudo Xvfb :10 -ac &

    2) Run export DISPLAY=:10

    3) Run java -jar "YOUR_PATH_TO/selenium-server-standalone-2.53.1.jar" -Dwebdriver.chrome.driver="YOUR_PATH_TO/chromedriver.2.27" -Dwebdriver.chrome.whitelistedIps="localhost"

    0 讨论(0)
  • 2020-11-30 06:26

    I saw this error

    Only local connections are allowed
    

    And I updated both the selenium webdriver, and the google-chrome-stable package

    webdriver-manager update
    zypper install google-chrome-stable
    

    This site reports the latest version of the chrome driver https://sites.google.com/a/chromium.org/chromedriver/

    My working versions are chromedriver 2.41 and google-chrome-stable 68

    0 讨论(0)
  • 2020-11-30 06:29

    For me, updating the chromedriver and selenium version removed this message.

    However, this is not an actual error and just an informational message. If your program is still passing with exit code 0 at the end even when this message is printed, it means the execution went fine.

    0 讨论(0)
提交回复
热议问题