|
18 | 18 | package org.openqa.selenium.safari;
|
19 | 19 |
|
20 | 20 | import com.google.auto.service.AutoService;
|
| 21 | +import java.util.HashMap; |
21 | 22 | import java.util.Map;
|
22 | 23 | import java.util.function.Predicate;
|
23 | 24 | import org.openqa.selenium.Capabilities;
|
@@ -66,9 +67,21 @@ public void setPermissions(String permission, boolean value) {
|
66 | 67 |
|
67 | 68 | @Override
|
68 | 69 | public Map<String, Boolean> getPermissions() {
|
69 |
| - Map<String, Object> results = |
70 |
| - (Map<String, Object>) executeMethod.execute(GET_PERMISSIONS, null); |
71 |
| - return (Map<String, Boolean>) results.get("permissions"); |
| 70 | + Object resultObject = executeMethod.execute(GET_PERMISSIONS, null); |
| 71 | + |
| 72 | + if (resultObject instanceof Map<?, ?>) { |
| 73 | + Map<?, ?> resultMap = (Map<?, ?>) resultObject; |
| 74 | + Map<String, Boolean> permissionMap = new HashMap<>(); |
| 75 | + for (Map.Entry<?, ?> entry : resultMap.entrySet()) { |
| 76 | + if (entry.getKey() instanceof String && entry.getValue() instanceof Boolean) { |
| 77 | + permissionMap.put((String) entry.getKey(), (Boolean) entry.getValue()); |
| 78 | + } |
| 79 | + } |
| 80 | + return permissionMap; |
| 81 | + } else { |
| 82 | + throw new IllegalStateException( |
| 83 | + "Unexpected result type: " + resultObject.getClass().getName()); |
| 84 | + } |
72 | 85 | }
|
73 | 86 | };
|
74 | 87 | }
|
|
0 commit comments