Firefox 37运行JavaScript遇匹配能力集错误,求非升级解决方案
Got it, let's tackle this problem without upgrading Firefox 37—totally get why you want to stick with it for Firepath compatibility. The error you're seeing comes down to modern Selenium versions defaulting to GeckoDriver, which doesn't play nice with Firefox 37's pre-Marionette architecture. Here's how to fix it without touching your Firefox version:
1. 降级Selenium到兼容版本
Firefox 37 pairs perfectly with Selenium 2.48.x (I recommend 2.48.2 specifically). This is the last Selenium release that natively supports older Firefox versions without requiring GeckoDriver.
- If you're using Maven, update your pom.xml dependency:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.48.2</version> </dependency> - If you're using standalone JARs, grab the 2.48.2 Selenium Java archive and replace your current high-version Selenium files.
2. 配置DesiredCapabilities强制禁用Marionette
In your JavaScript script, explicitly tell Selenium to use the old FirefoxDriver instead of GeckoDriver by setting these capabilities:
var capabilities = webdriver.Capabilities.firefox(); capabilities.setCapability("marionette", false); capabilities.setCapability("firefox_version", "37"); // Lock to your Firefox version var driver = new webdriver.Builder().withCapabilities(capabilities).build();
This forces Selenium to skip GeckoDriver entirely and use the native driver that works with Firefox 37.
3. Match Firepath to Firefox 37
Make sure your Firepath version is compatible too—Firepath 0.9.7 is built for Firefox 30-40. If you have a newer Firepath installed, it might clash with Firefox 37 and cause unexpected issues, so roll back to this version if needed.
4. Disable Firefox Auto-Update
To keep your Firefox 37 setup intact, turn off automatic updates:
- Open Firefox 37, go to
Options→Advanced→Updates - Select "Never check for updates (not recommended, but necessary here)" and save the setting.
Quick Notes
- Don't specify a GeckoDriver path in your script—this will force Selenium to try using it, which breaks compatibility.
- If GeckoDriver is in your system PATH, remove it temporarily to avoid accidental calls.
内容的提问来源于stack exchange,提问作者Rohn Kerry

