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

chore: Change getDeviceTime to call the mobile implementation #1332

Merged
merged 2 commits into from
Apr 4, 2020
Merged
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: 10 additions & 1 deletion src/main/java/io/appium/java_client/HasDeviceTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

import static io.appium.java_client.MobileCommand.GET_DEVICE_TIME;

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

import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.Response;

import java.util.Map;

public interface HasDeviceTime extends ExecutesMethod {

/**
Expand All @@ -31,10 +35,15 @@ public interface HasDeviceTime extends ExecutesMethod {
* https://momentjs.com/docs/ to get the full list of supported
* datetime format specifiers. The default format is
* `YYYY-MM-DDTHH:mm:ssZ`, which complies to ISO-8601
* @since Appium 1.18
* @return Device time string
*/
default String getDeviceTime(String format) {
Response response = execute(GET_DEVICE_TIME, ImmutableMap.of("format", format));
Map<String, ?> params = ImmutableMap.of(
"script", "mobile: getDeviceTime",
"args", ImmutableList.of(ImmutableMap.of("format", format))
);
Response response = execute(DriverCommand.EXECUTE_SCRIPT, params);
return response.getValue().toString();
}

Expand Down