You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java版本变更后Protractor测试报错ChromeDriverService创建失败求助

Fix: Unable to Create ChromeDriverService in Protractor After Environment Changes

Hey there, it looks like your environment tweaks (switching Java versions, uninstalling Appium) left some lingering issues with Protractor's ChromeDriver setup. Let's walk through targeted fixes to get your tests running again:

1. Verify Chrome Browser ↔ ChromeDriver Version Match

Your ChromeDriver is version 79—this must exactly match the version of Chrome installed on your machine. Chrome auto-updates often, so this is the most common culprit here:

  • Check your Chrome version: Open Chrome → Menu (three dots) → Help → About Google Chrome
  • If versions don't align:
    • Either downgrade Chrome to 79.x, or download the ChromeDriver that matches your current Chrome version
    • Replace the old driver in webdriver-manager's cache: Navigate to C:\Users\alexandre\.webdriver-manager\chromedriver\win32\, delete the existing chromedriver.exe, and drop in the matching version

2. Nuke and Reinstall Webdriver-Manager

Environment changes can corrupt webdriver-manager's cache or dependencies. Run these commands in a fresh command prompt:

# Uninstall global webdriver-manager
npm uninstall -g webdriver-manager
# Clear npm's cache to eliminate corrupted files
npm cache clean --force
# Reinstall webdriver-manager
npm install -g webdriver-manager
# Force update to your target ChromeDriver version (79 in your case)
webdriver-manager update --versions.chrome=79.0.3945.36

3. Double-Check Java Environment Variables

Even though you're on Java 8, misconfigured env vars can break Selenium/ChromeDriver:

  • Confirm JAVA_HOME points to your Java 8 installation (e.g., C:\Program Files\Java\jdk1.8.0_231)
  • Ensure %JAVA_HOME%\bin is at the top of your Path variable (no old Java paths above it)
  • Test with these commands in a new prompt to confirm:
    java -version
    javac -version
    
    Both should output Java 8 details.

4. Hardcode ChromeDriver Path in Protractor Config

Force Protractor to use the correct driver by updating your protractor.conf.js:

exports.config = {
  // ... your existing config
  chromeDriver: 'C:\\Users\\alexandre\\.webdriver-manager\\chromedriver\\win32\\79.0.3945.36\\chromedriver.exe',
  directConnect: true, // Skip Selenium Server for direct ChromeDriver connection
  // ...
};

directConnect simplifies the setup and avoids potential Selenium Server issues (your Protractor 5.4.2 version supports this fully).

5. Troubleshoot Selenium Server (If You Need It)

If you must use the Selenium Server instead of directConnect:

  • Kill all lingering processes: Open Task Manager and end chromedriver.exe, selenium-server-standalone-*.jar, and any stray node.exe instances
  • Start the server manually to catch errors:
    webdriver-manager start --versions.chrome=79.0.3945.36
    
    If you get a port conflict error, use a different port and update your Protractor config:
    webdriver-manager start --port=4445
    
    Then set seleniumAddress: 'http://localhost:4445/wd/hub' in your config.

6. Validate with a Minimal Test

Create a simple test to rule out project-specific issues:

  1. Make a test.js config file:
exports.config = {
  directConnect: true,
  specs: ['spec.js'],
};
  1. Make a spec.js test file:
describe('Basic Test', () => {
  it('should load Google', () => {
    browser.get('https://google.com');
    expect(browser.getTitle()).toEqual('Google');
  });
});
  1. Run it with:
protractor test.js

Work through these steps one by one—this should resolve the ChromeDriverService creation error you're seeing.

内容的提问来源于stack exchange,提问作者Alexandre

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:13:03