int numberOfFieldsMatched = 0;
Class<? extends WebDriver> bestMatch = null;
for (Map.Entry<Capabilities, Class<? extends WebDriver>> entry : capabilitiesToDriver.entrySet()) {
int count = 0;
Capabilities caps = entry.getKey();
if (matches(caps.getBrowserName(), desired.getBrowserName())) {
count++;
}
if (matches(caps.getVersion(), desired.getVersion())) {
count++;
}
if (caps.isJavascriptEnabled() == desired.isJavascriptEnabled()) {
count++;
}
Platform capPlatform = caps.getPlatform();
Platform desiredPlatform = desired.getPlatform();
if (capPlatform != null && desiredPlatform != null) {
if (capPlatform.is(desiredPlatform)) {
count++;