Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code changes for getting all session details #1167

Merged
merged 5 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/java/io/appium/java_client/HasSessionDetails.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
package io.appium.java_client;

import static io.appium.java_client.MobileCommand.GET_SESSION;
import static io.appium.java_client.MobileCommand.GET_ALLSESSION;
SrinivasanTarget marked this conversation as resolved.
Show resolved Hide resolved
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toMap;
import static org.apache.commons.lang3.StringUtils.isBlank;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.remote.Response;

import java.util.Arrays;
SrinivasanTarget marked this conversation as resolved.
Show resolved Hide resolved
import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

public interface HasSessionDetails extends ExecutesMethod {
Expand Down Expand Up @@ -86,4 +91,16 @@ default boolean isBrowser() {
return ofNullable(getSessionDetail("browserName"))
.orElse(null) != null;
}

/**
* Get All Sessions details
* @return List of Map objects with All Session Details
SrinivasanTarget marked this conversation as resolved.
Show resolved Hide resolved
*/
@SuppressWarnings("unchecked")
default List<Map<String, Object>> getAllSessionDetails() {
Response response = execute(GET_ALLSESSION);
List<Map<String,Object>> resultSet = List.class.cast(response.getValue());
return ImmutableList.<Map<String,Object>>builder().addAll(resultSet).build();
}

}
4 changes: 4 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class MobileCommand {
protected static final String TOGGLE_DATA;
protected static final String COMPARE_IMAGES;
protected static final String EXECUTE_DRIVER_SCRIPT;
protected static final String GET_ALLSESSION;

public static final Map<String, CommandInfo> commandRepository;

Expand Down Expand Up @@ -186,6 +187,7 @@ public class MobileCommand {
TOGGLE_DATA = "toggleData";
COMPARE_IMAGES = "compareImages";
EXECUTE_DRIVER_SCRIPT = "executeDriverScript";
GET_ALLSESSION = "getAllSessions";

commandRepository = new HashMap<>();
commandRepository.put(RESET, postC("/session/:sessionId/appium/app/reset"));
Expand Down Expand Up @@ -271,6 +273,8 @@ public class MobileCommand {
commandRepository.put(TOGGLE_DATA, postC("/session/:sessionId/appium/device/toggle_data"));
commandRepository.put(COMPARE_IMAGES, postC("/session/:sessionId/appium/compare_images"));
commandRepository.put(EXECUTE_DRIVER_SCRIPT, postC("/session/:sessionId/appium/execute_driver"));
//Get All Session Details
SrinivasanTarget marked this conversation as resolved.
Show resolved Hide resolved
commandRepository.put(GET_ALLSESSION, getC("/sessions"));
}

/**
Expand Down
Loading