File tree 3 files changed +23
-0
lines changed
main/java/io/appium/java_client
test/java/io/appium/java_client/android
3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package io .appium .java_client ;
18
18
19
+ import static io .appium .java_client .MobileCommand .GET_ALLSESSION ;
19
20
import static io .appium .java_client .MobileCommand .GET_SESSION ;
20
21
import static java .util .Optional .ofNullable ;
21
22
import static java .util .stream .Collectors .toMap ;
22
23
import static org .apache .commons .lang3 .StringUtils .isBlank ;
23
24
25
+ import com .google .common .collect .ImmutableList ;
24
26
import com .google .common .collect .ImmutableMap ;
25
27
26
28
import org .openqa .selenium .remote .Response ;
27
29
30
+ import java .util .List ;
28
31
import java .util .Map ;
29
32
import javax .annotation .Nullable ;
30
33
@@ -86,4 +89,16 @@ default boolean isBrowser() {
86
89
return ofNullable (getSessionDetail ("browserName" ))
87
90
.orElse (null ) != null ;
88
91
}
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
+ }
89
104
}
Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ public class MobileCommand {
111
111
protected static final String TOGGLE_DATA ;
112
112
protected static final String COMPARE_IMAGES ;
113
113
protected static final String EXECUTE_DRIVER_SCRIPT ;
114
+ protected static final String GET_ALLSESSION ;
114
115
115
116
public static final Map <String , CommandInfo > commandRepository ;
116
117
@@ -186,6 +187,7 @@ public class MobileCommand {
186
187
TOGGLE_DATA = "toggleData" ;
187
188
COMPARE_IMAGES = "compareImages" ;
188
189
EXECUTE_DRIVER_SCRIPT = "executeDriverScript" ;
190
+ GET_ALLSESSION = "getAllSessions" ;
189
191
190
192
commandRepository = new HashMap <>();
191
193
commandRepository .put (RESET , postC ("/session/:sessionId/appium/app/reset" ));
@@ -271,6 +273,7 @@ public class MobileCommand {
271
273
commandRepository .put (TOGGLE_DATA , postC ("/session/:sessionId/appium/device/toggle_data" ));
272
274
commandRepository .put (COMPARE_IMAGES , postC ("/session/:sessionId/appium/compare_images" ));
273
275
commandRepository .put (EXECUTE_DRIVER_SCRIPT , postC ("/session/:sessionId/appium/execute_driver" ));
276
+ commandRepository .put (GET_ALLSESSION , getC ("/sessions" ));
274
277
}
275
278
276
279
/**
Original file line number Diff line number Diff line change @@ -314,5 +314,10 @@ public void getPerformanceDataTest() {
314
314
public void getCurrentPackageTest () {
315
315
assertEquals (APP_ID , driver .getCurrentPackage ());
316
316
}
317
+
318
+ @ Test public void validateAllSessions () {
319
+ List <Map <String ,Object >> jsonMap = driver .getAllSessionDetails ();
320
+ assertNotNull (jsonMap );
321
+ }
317
322
318
323
}
You can’t perform that action at this time.
0 commit comments