diff --git a/src/main/java/io/appium/java_client/remote/NewAppiumSessionPayload.java b/src/main/java/io/appium/java_client/remote/NewAppiumSessionPayload.java index 5f74ed35a..5cf261a45 100644 --- a/src/main/java/io/appium/java_client/remote/NewAppiumSessionPayload.java +++ b/src/main/java/io/appium/java_client/remote/NewAppiumSessionPayload.java @@ -268,16 +268,14 @@ public void writeTo(Appendable appendable) throws IOException { json.name(CAPABILITIES); json.beginObject(); - json.name(DESIRED_CAPABILITIES); - json.write(first); - - // Then write everything into the w3c payload. Because of the way we do this, it's easiest - // to just populate the "firstMatch" section. The spec says it's fine to omit the - // "alwaysMatch" field, so we do this. + json.name(ALWAYS_MATCH); + getW3C().forEach(json::write); + json.name(FIRST_MATCH); json.beginArray(); //noinspection unchecked - getW3C().forEach(json::write); + json.beginObject(); + json.endObject(); json.endArray(); json.endObject(); // Close "capabilities" object @@ -547,4 +545,4 @@ private Map applyTransforms(Map caps) { } return toReturn; } -} \ No newline at end of file +}