Java版本变更后Protractor测试报错ChromeDriverService创建失败求助
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 existingchromedriver.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_HOMEpoints to your Java 8 installation (e.g.,C:\Program Files\Java\jdk1.8.0_231) - Ensure
%JAVA_HOME%\binis at the top of yourPathvariable (no old Java paths above it) - Test with these commands in a new prompt to confirm:
Both should output Java 8 details.java -version javac -version
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 straynode.exeinstances - Start the server manually to catch errors:
If you get a port conflict error, use a different port and update your Protractor config:webdriver-manager start --versions.chrome=79.0.3945.36
Then setwebdriver-manager start --port=4445seleniumAddress: 'http://localhost:4445/wd/hub'in your config.
6. Validate with a Minimal Test
Create a simple test to rule out project-specific issues:
- Make a
test.jsconfig file:
exports.config = { directConnect: true, specs: ['spec.js'], };
- Make a
spec.jstest file:
describe('Basic Test', () => { it('should load Google', () => { browser.get('https://google.com'); expect(browser.getTitle()).toEqual('Google'); }); });
- 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

