Polymer 2测试报错求助:指定Chrome却请求微软地址及启动失败
Fixing Polymer 2 Testing Issues on Windows 7
Hey there, let's work through these two frustrating test errors you're hitting with Polymer 2 on Windows 7. I've seen similar quirks with Web Component Tester (WCT) on older Windows systems, so here's how to tackle each problem:
Problem 1: polymer test -l chrome tries to download MicrosoftWebDriver
Even though you're only targeting Chrome, WCT has a default behavior on Windows that checks for IE driver files—hence the failed request to Microsoft's download server. Here's how to override this:
- Create a
wct.conf.jsonfile in your project root directory if you don't already have one. - Add this configuration to explicitly target Chrome and disable IE-related checks:
{ "plugins": { "local": { "browsers": ["chrome"], "skipSeleniumInstall": true, "chrome": { "binary": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", "driver": "C:/path/to/your/chromedriver.exe" } } } }
- Important: Download the correct version of ChromeDriver that matches your installed Chrome version (check Chrome's "About" page for your version number). Place the
chromedriver.exein the path you specified above, or add it to your system'sPATHenvironment variable.
Problem 2: polymer test --skip-selenium-install throws "session not created" error
This error happens because you skipped the auto-install, but WCT can't find a valid ChromeDriver to start the test session. Follow these steps to fix it:
- Match Chrome and ChromeDriver versions: Windows 7 only supports Chrome up to version 109, so if you're running a newer Chrome, downgrade to 109 and grab the corresponding ChromeDriver. Always ensure your ChromeDriver version exactly matches your Chrome browser version.
- Verify ChromeDriver accessibility: Either add ChromeDriver to your system
PATH, or specify its full path in thewct.conf.jsonas shown in the first fix. - Run with admin privileges: Sometimes Windows 7's file permissions block WCT from accessing driver files. Try opening your command prompt as Administrator before running the test command.
Bonus Troubleshooting Tips
- Update your
polymer-cliandweb-component-testerto the latest stable versions (runnpm update -g polymer-cli). Older versions had more compatibility issues with Windows 7. - If you still hit network-related hiccups, double-check your firewall settings—sometimes corporate or local firewalls block access to driver download servers (though we're bypassing that with manual driver setup anyway).
内容的提问来源于stack exchange,提问作者Jim C
相关产品推荐
相关产品推荐

