File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed
main/java/io/appium/java_client
test/java/io/appium/java_client/android Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 1616
1717package io .appium .java_client ;
1818
19+ import static io .appium .java_client .MobileCommand .GET_ALLSESSION ;
1920import static io .appium .java_client .MobileCommand .GET_SESSION ;
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 .List ;
2831import java .util .Map ;
2932import javax .annotation .Nullable ;
3033
@@ -86,4 +89,16 @@ default boolean isBrowser() {
8689 return ofNullable (getSessionDetail ("browserName" ))
8790 .orElse (null ) != null ;
8891 }
92+
93+ /**
94+ * Get All Sessions details.
95+ *
96+ * @return List of Map objects with All Session Details.
97+ */
98+ @ SuppressWarnings ("unchecked" )
99+ default List <Map <String , Object >> getAllSessionDetails () {
100+ Response response = execute (GET_ALLSESSION );
101+ List <Map <String ,Object >> resultSet = List .class .cast (response .getValue ());
102+ return ImmutableList .<Map <String ,Object >>builder ().addAll (resultSet ).build ();
103+ }
89104}
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,7 @@ 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+ commandRepository .put (GET_ALLSESSION , getC ("/sessions" ));
274277 }
275278
276279 /**
Original file line number Diff line number Diff line change @@ -314,5 +314,10 @@ public void getPerformanceDataTest() {
314314 public void getCurrentPackageTest () {
315315 assertEquals (APP_ID , driver .getCurrentPackage ());
316316 }
317+
318+ @ Test public void validateAllSessions () {
319+ List <Map <String ,Object >> jsonMap = driver .getAllSessionDetails ();
320+ assertNotNull (jsonMap );
321+ }
317322
318323}
You can’t perform that action at this time.
0 commit comments