Skip to content

added getSession api to fetch deviceUDID #403

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

Merged
merged 3 commits into from
Jun 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
package io.appium.java_client;

import static com.google.common.base.Preconditions.checkNotNull;

import static io.appium.java_client.MobileCommand.CLOSE_APP;
import static io.appium.java_client.MobileCommand.GET_DEVICE_TIME;
import static io.appium.java_client.MobileCommand.GET_SESSION;
import static io.appium.java_client.MobileCommand.GET_SETTINGS;
import static io.appium.java_client.MobileCommand.GET_STRINGS;
import static io.appium.java_client.MobileCommand.HIDE_KEYBOARD;
Expand Down Expand Up @@ -682,4 +684,13 @@ private TouchAction createTap(int x, int y, int duration) {
public URL getRemoteAddress() {
return remoteAddress;
}

/**
* @return a map with values that hold session details.
*
*/
public Map<String, String> getSessionDetails() {
Response response = execute(GET_SESSION);
return (Map<String, String>) response.getValue();
}
}
4 changes: 3 additions & 1 deletion src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class MobileCommand {
public static final String TOGGLE_LOCATION_SERVICES = "toggleLocationServices";
public static final String GET_DEVICE_TIME = "getDeviceTime";
public static final String UNLOCK = "unlock";
public static final String GET_SESSION = "getSession";
public static final Map<String, CommandInfo> commandRepository = getMobileCommands();

public static CommandInfo getC(String url) {
Expand Down Expand Up @@ -111,7 +112,8 @@ private static Map<String, CommandInfo> getMobileCommands() {
.put(TOGGLE_LOCATION_SERVICES,
postC("/session/:sessionId/appium/device/toggle_location_services"))
.put(GET_DEVICE_TIME, getC("/session/:sessionId/appium/device/system_time"))
.put(UNLOCK, postC("/session/:sessionId/appium/device/unlock"));
.put(UNLOCK, postC("/session/:sessionId/appium/device/unlock"))
.put(GET_SESSION,getC("/session/:sessionId/"));

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;


import io.appium.java_client.AppiumSetting;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -134,4 +136,9 @@ public class AndroidDriverTest extends BaseAndroidTest {
@Test public void endTestCoverage() {
driver.endTestCoverage("android.intent.action.MAIN", "");
}

@Test public void getDeviceUDIDTest() {
String deviceSerial = driver.getSessionDetails().get("deviceUDID");
assertNotNull(deviceSerial);
}
}