Skip to content

Commit fc6e323

Browse files
committed
Use fallback method
1 parent 610d6ec commit fc6e323

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dotnet/src/webdriver/DevTools/DevToolsDomains.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ public static DevToolsDomains InitializeDomains(int protocolVersion, DevToolsSes
114114
return domains;
115115
}
116116

117+
return CreateFallbackDomain(protocolVersion, session, versionRange);
118+
}
119+
120+
private static DevToolsDomains CreateFallbackDomain(int desiredVersion, DevToolsSession session, int versionRange)
121+
{
117122
// Get the list of supported versions and sort descending
118123
List<int> supportedVersions = new List<int>(SupportedProtocolVersions);
119124
supportedVersions.Sort((first, second) => second.CompareTo(first));
@@ -123,13 +128,13 @@ public static DevToolsDomains InitializeDomains(int protocolVersion, DevToolsSes
123128
// Match the version with the desired version within the
124129
// version range, using "The Price Is Right" style matching
125130
// (that is, closest without going over).
126-
if (protocolVersion >= supportedVersion && protocolVersion - supportedVersion < versionRange)
131+
if (desiredVersion >= supportedVersion && desiredVersion - supportedVersion < versionRange)
127132
{
128133
return CreateDevToolsDomain(supportedVersion, session)!;
129134
}
130135
}
131136

132-
throw new WebDriverException($"DevTools version is not in the supported range. Desired version={protocolVersion}, range={versionRange}. Supported versions: {string.Join(", ", supportedVersions)}");
137+
throw new WebDriverException($"DevTools version is not in the supported range. Desired version={desiredVersion}, range={versionRange}. Supported versions: {string.Join(", ", supportedVersions)}");
133138
}
134139
}
135140
}

0 commit comments

Comments
 (0)