org.openqa.selenium.WebDriverException: unknown er

2018-12-31 05:42发布

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 open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)

My configuration:

Chrome : 66 ChromeBrowser : 2.39.56

P.S everything works fine in Firefox

12条回答
弹指情弦暗扣
2楼-- · 2018-12-31 06:07

I had the same issue, but in my case chrome previously was installed in user temp folder, after that was reinstalled to Program files. So any of solution provided here was not help me. But if provide path to chrome.exe all works:

chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");

I hope this helps someone =)

查看更多
孤独总比滥情好
3楼-- · 2018-12-31 06:08

Update:

I am able to get through the issue and now I am able to access the chrome with desired url.

Results of trying the provided solutions:

I tried all the settings as provided above but I was unable to resolve the issue

Explanation regarding the issue:

As per my observation DevToolsActivePort file doesn't exist is caused when chrome is unable to find its reference in scoped_dirXXXXX folder.

Steps taken to solve the issue

  1. I have killed all the chrome processes and chrome driver processes.
  2. Added the below code to invoke the chrome

    System.setProperty("webdriver.chrome.driver","pathto\\chromedriver.exe");    
    ChromeOptions options = new ChromeOptions();
    options.setExperimentalOption("useAutomationExtension", false);
    WebDriver driver = new ChromeDriver(options);
    driver.get(url);
    

Using the above steps I was able to resolve the issue.

Thanks for your answers.

查看更多
泪湿衣
4楼-- · 2018-12-31 06:11

In my case it happened when I've tried to use my default user profile:

...
options.addArguments("user-data-dir=D:\\MyHomeDirectory\\Google\\Chrome\\User Data");
...

This triggered chrome to reuse processes already running in background, in such a way, that process started by chromedriver.exe was simply ended.

Resolution: kill all chrome.exe processes running in background.

查看更多
唯独是你
5楼-- · 2018-12-31 06:13

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!

查看更多
宁负流年不负卿
6楼-- · 2018-12-31 06:15

I solve this problem by installing yum -y install gtk3-devel gtk3-devel-docs", it works ok

My work env is :

Selenium Version 3.12.0
ChromeDriver Version v2.40
Chrome 68 level

Before:
enter image description here enter image description here

After:
enter image description here enter image description here

查看更多
高级女魔头
7楼-- · 2018-12-31 06:16

I had the same problem in python. The above helped. Here is what I used in python -

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome('/path/to/your_chrome_driver_dir/chromedriver',chrome_options=chrome_options)
查看更多
登录 后发表回答