|
12 | 12 | import static utam.core.framework.UtamLogger.warning; |
13 | 13 |
|
14 | 14 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 15 | +import com.fasterxml.jackson.databind.JsonNode; |
15 | 16 | import com.fasterxml.jackson.databind.ObjectMapper; |
16 | 17 | import io.appium.java_client.AppiumDriver; |
17 | 18 | import io.appium.java_client.remote.SupportsContextSwitching; |
@@ -140,15 +141,16 @@ private static AppiumDriver checkAndroidWebViewContext( |
140 | 141 | for (Map<String, Object> page : pages) { |
141 | 142 | String newTitle = (String) page.get(WEBVIEW_TITLE_KEY_ANDROID); |
142 | 143 | // 'description' doesn't cast to Map, only String |
143 | | - String jsonString = (String) page.get(WEBVIEW_PAGE_DESCRIPTION_KEY); |
144 | | - Map description = null; |
| 144 | + String serializedDescription = (String) page.get(WEBVIEW_PAGE_DESCRIPTION_KEY); |
| 145 | + boolean visible = false; |
145 | 146 | try { |
146 | | - description = new ObjectMapper().readValue(jsonString, Map.class); |
| 147 | + JsonNode descriptionNode = new ObjectMapper().readTree(serializedDescription); |
| 148 | + if (descriptionNode.has(WEBVIEW_PAGE_DESCRIPTION_VISIBILITY_KEY)) { |
| 149 | + visible = descriptionNode.get(WEBVIEW_PAGE_DESCRIPTION_VISIBILITY_KEY).asBoolean(); |
| 150 | + } |
147 | 151 | } catch (JsonProcessingException e) { |
148 | 152 | error(e); |
149 | 153 | } |
150 | | - boolean visible = |
151 | | - description != null && (boolean) description.get(WEBVIEW_PAGE_DESCRIPTION_VISIBILITY_KEY); |
152 | 154 | if (newTitle.equalsIgnoreCase(title) && visible) { |
153 | 155 | String id = (String) page.get(WEBVIEW_PAGE_KEY); |
154 | 156 | AppiumDriver newDriver = switchToContext(appiumDriver, webviewName, id); |
|
0 commit comments