Skip to content

Commit 95c4d51

Browse files
committed
Fixing platform conversion, step 2 (also more tests to be added on step 3)
1 parent 396f255 commit 95c4d51

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

java/client/src/org/openqa/selenium/Platform.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,18 @@ public static Platform extractFromSysProperty(String osName, String osVersion) {
210210
* @return the Platform enum value matching the parameter
211211
*/
212212
public static Platform fromString(String name) {
213-
for (Platform os : Platform.values()) {
214-
for (String matcher : os.partOfOsName) {
215-
if (name.toLowerCase().equals(matcher.toLowerCase())) {
216-
return os;
213+
try {
214+
return Platform.valueOf(name);
215+
} catch (IllegalArgumentException ex) {
216+
for (Platform os : Platform.values()) {
217+
for (String matcher : os.partOfOsName) {
218+
if (name.toLowerCase().equals(matcher.toLowerCase())) {
219+
return os;
220+
}
217221
}
218222
}
223+
throw new WebDriverException("Unrecognized platform: " + name);
219224
}
220-
throw new WebDriverException("Unknown platform: " + name);
221225
}
222226

223227
/**

0 commit comments

Comments
 (0)