File tree Expand file tree Collapse file tree 3 files changed +297
-271
lines changed
main/java/io/appium/java_client
test/java/io/appium/java_client/android Expand file tree Collapse file tree 3 files changed +297
-271
lines changed Original file line number Diff line number Diff line change 1717package io .appium .java_client ;
1818
1919import static io .appium .java_client .MobileCommand .GET_SESSION ;
20+ import static io .appium .java_client .MobileCommand .GET_ALLSESSION ;
2021import static java .util .Optional .ofNullable ;
2122import static java .util .stream .Collectors .toMap ;
2223import static org .apache .commons .lang3 .StringUtils .isBlank ;
2324
25+ import com .google .common .collect .ImmutableList ;
2426import com .google .common .collect .ImmutableMap ;
2527
2628import org .openqa .selenium .remote .Response ;
2729
30+ import java .util .Arrays ;
31+ import java .util .List ;
2832import java .util .Map ;
33+
2934import javax .annotation .Nullable ;
3035
3136public interface HasSessionDetails extends ExecutesMethod {
@@ -86,4 +91,16 @@ default boolean isBrowser() {
8691 return ofNullable (getSessionDetail ("browserName" ))
8792 .orElse (null ) != null ;
8893 }
94+
95+ /**
96+ * Get All Sessions details
97+ * @return List of Map objects with All Session Details
98+ */
99+ @ SuppressWarnings ("unchecked" )
100+ default List <Map <String , Object >> getAllSessionDetails () {
101+ Response response = execute (GET_ALLSESSION );
102+ List <Map <String ,Object >> resultSet = List .class .cast (response .getValue ());
103+ return ImmutableList .<Map <String ,Object >>builder ().addAll (resultSet ).build ();
104+ }
105+
89106}
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ public class MobileCommand {
111111 protected static final String TOGGLE_DATA ;
112112 protected static final String COMPARE_IMAGES ;
113113 protected static final String EXECUTE_DRIVER_SCRIPT ;
114+ protected static final String GET_ALLSESSION ;
114115
115116 public static final Map <String , CommandInfo > commandRepository ;
116117
@@ -186,6 +187,7 @@ public class MobileCommand {
186187 TOGGLE_DATA = "toggleData" ;
187188 COMPARE_IMAGES = "compareImages" ;
188189 EXECUTE_DRIVER_SCRIPT = "executeDriverScript" ;
190+ GET_ALLSESSION = "getAllSessions" ;
189191
190192 commandRepository = new HashMap <>();
191193 commandRepository .put (RESET , postC ("/session/:sessionId/appium/app/reset" ));
@@ -271,6 +273,8 @@ public class MobileCommand {
271273 commandRepository .put (TOGGLE_DATA , postC ("/session/:sessionId/appium/device/toggle_data" ));
272274 commandRepository .put (COMPARE_IMAGES , postC ("/session/:sessionId/appium/compare_images" ));
273275 commandRepository .put (EXECUTE_DRIVER_SCRIPT , postC ("/session/:sessionId/appium/execute_driver" ));
276+ //Get All Session Details
277+ commandRepository .put (GET_ALLSESSION , getC ("/sessions" ));
274278 }
275279
276280 /**
You can’t perform that action at this time.
0 commit comments