WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser

前端 未结 29 3345
旧巷少年郎
旧巷少年郎 2020-11-21 07:11

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         


        
29条回答
  •  北海茫月
    2020-11-21 07:22

    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!

提交回复
热议问题