Selenium-Chrome-Headless : Unable to receive messa

2020-06-28 04:43发布

问题:

I am using Chrome-latest stable version 61.0.3163.79 Chomedriver 2.31 Selenium 3.4.0 Jenkins and docker

My first run over Jenkins getting error as below:

1.732][INFO]: Done waiting for pending navigations. Status: disconnected: Unable to receive message from renderer [1.732][DEBUG]: DevTools request: http://localhost:12059/json [1.733][DEBUG]: DevTools request failed

Can someone please assist me how can I solve this?

回答1:

chromeOptions.addArguments(dimension);
    chromeOptions.addArguments("--disable-gpu");
    chromeOptions.addArguments("--no-sandbox");
    chromeOptions.setBinary("/usr/bin/google-chrome");
    System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
    Logger.getLogger("org.openqa.selenium.remote").setLevel(Level.OFF);
    System.setProperty("webdriver.chrome.logfile", "target/chromedriver.log");
    ChromeDriverService service =
            new ChromeDriverService.Builder().withWhitelistedIps("").withVerbose(true).build();
    driver = new ChromeDriver(service, chromeOptions);
    driver.get(domain);

also mount volumes on server: /dev/shm:/dev/shm

This fixed my issue