使用Selenium+GeckoDriver遇“Unable to read VR Path Registry from”错误求助
Environment Info
- Version:
geckodriver-v0.20.0-win64 - OS: Windows 10 Home Single
- Browser: Firefox 59.0.2 (64-bit)
- Selenium Version:
selenium-java-3.11.0 - IDE: IntelliJ Idea 2018.1 Community Edition
What's Causing This Error?
First off, don’t panic too much—this is mostly a warning message rather than a critical failure that stops your WebDriver scripts from running. It pops up because geckodriver is trying to access VR (Virtual Reality) related registry settings on your Windows system that either don’t exist, are misconfigured, or aren’t supported by your older Firefox/geckodriver versions.
Step-by-Step Solutions
Let’s go through the fixes from easiest to more advanced:
1. Update Your Geckodriver & Firefox to Compatible Versions
Your current versions are pretty outdated (they date back to 2018), and older releases often have compatibility quirks like this warning.
- Grab the latest stable geckodriver for Windows 64-bit (make sure it matches your Firefox version—compatibility details are listed in geckodriver’s release notes).
- Upgrade Firefox to a newer maintained version (Firefox 115+ is a solid LTS choice, since older versions no longer receive updates).
- Double-check that geckodriver is still properly added to your Windows system PATH after updating.
2. Disable VR Features via FirefoxOptions
If you don’t need VR support at all, you can explicitly turn it off in your code to suppress the warning. Add these lines when initializing your FirefoxDriver:
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; public class YourTestClass { public static void main(String[] args) { FirefoxOptions options = new FirefoxOptions(); // Disable VR features to skip the registry check options.addArguments("--disable-features=Vr"); WebDriver driver = new FirefoxDriver(options); // Rest of your test code here... } }
3. Manually Fix the VR Registry Entry (Advanced)
If you’re comfortable editing the Windows Registry, you can create the missing VR path entry geckodriver is looking for:
- Press
Win + R, typeregedit, and hit Enter to open the Registry Editor. - Navigate to
HKEY_LOCAL_MACHINE\SOFTWARE\Khronos\OpenVR\Paths - If this path doesn’t exist, right-click on
Khronos, select New > Key, name itOpenVR, then right-clickOpenVRand create another Key namedPaths. - Close the Registry Editor and restart your IDE/test script.
Quick Note
If the warning doesn’t actually block your scripts from running, you can choose to ignore it—it’s just geckodriver logging a minor missing configuration, not a showstopper. But if you want clean log output, the fixes above should take care of it.
内容的提问来源于stack exchange,提问作者Lolaika BadtzMaru

