File tree 3 files changed +25
-6
lines changed
main/java/io/appium/java_client
test/java/io/appium/java_client
3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import static io .appium .java_client .MobileCommand .GET_DEVICE_TIME ;
20
20
21
+ import com .google .common .collect .ImmutableMap ;
22
+
21
23
import org .openqa .selenium .remote .Response ;
22
24
23
25
public interface HasDeviceTime extends ExecutesMethod {
24
- /*
25
- Gets device date and time for both iOS(Supports only real device) and Android devices
26
+
27
+ /**
28
+ * Gets device date and time for both iOS(host time is returned for simulators) and Android devices.
29
+ *
30
+ * @param format The set of format specifiers. Read
31
+ * https://momentjs.com/docs/ to get the full list of supported
32
+ * datetime format specifiers. The default format is
33
+ * `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601
34
+ * @return Device time string
35
+ */
36
+ default String getDeviceTime (String format ) {
37
+ Response response = execute (GET_DEVICE_TIME , ImmutableMap .of ("format" , format ));
38
+ return response .getValue ().toString ();
39
+ }
40
+
41
+ /**
42
+ * Gets device date and time for both iOS(host time is returned for simulators) and Android devices.
43
+ * The default format since Appium 1.8.2 is `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601.
44
+ *
45
+ * @return Device time string
26
46
*/
27
47
default String getDeviceTime () {
28
48
Response response = execute (GET_DEVICE_TIME );
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ public class AndroidDriverTest extends BaseAndroidTest {
118
118
119
119
@ Test public void getDeviceTimeTest () {
120
120
String time = driver .getDeviceTime ();
121
- assertTrue (time .length () == 28 );
121
+ assertFalse (time .isEmpty () );
122
122
}
123
123
124
124
@ Test public void isAppInstalledTest () {
Original file line number Diff line number Diff line change 30
30
31
31
public class IOSDriverTest extends AppIOSTest {
32
32
33
- //TODO There is no ability to check this function usibg simulators.
34
- // When CI will have been set up then this test will be returned
33
+ @ Test
35
34
public void getDeviceTimeTest () {
36
35
String time = driver .getDeviceTime ();
37
- assertTrue (time .length () == 28 );
36
+ assertFalse (time .isEmpty () );
38
37
}
39
38
40
39
@ Test public void resetTest () {
You can’t perform that action at this time.
0 commit comments