1818
1919import io .appium .java_client .CommandExecutionHelper ;
2020import io .appium .java_client .ExecutesMethod ;
21+ import io .appium .java_client .Location ;
2122import io .appium .java_client .MobileCommand ;
2223import org .openqa .selenium .WebDriver ;
2324import org .openqa .selenium .WebDriverException ;
24- import org .openqa .selenium .html5 .Location ;
25- import org .openqa .selenium .html5 .LocationContext ;
26- import org .openqa .selenium .remote .html5 .RemoteLocationContext ;
2725
2826import java .util .HashMap ;
2927import java .util .Map ;
3028import java .util .Optional ;
3129
32- public interface SupportsLocation extends WebDriver , ExecutesMethod , LocationContext {
33-
34- /**
35- * Provides the location context.
36- *
37- * @return instance of {@link RemoteLocationContext}
38- * @deprecated This method, {@link LocationContext} and {@link RemoteLocationContext} interface are deprecated, use
39- * {@link #getLocation()} and {@link #setLocation(io.appium.java_client.Location)} instead.
40- */
41- @ Deprecated (forRemoval = true )
42- RemoteLocationContext getLocationContext ();
43-
44- /**
45- * Gets the current device's geolocation coordinates.
46- *
47- * @return A {@link Location} containing the location information. Returns null if the location is not available
48- * @deprecated This method and whole {@link LocationContext} interface are deprecated, use {@link #getLocation()}
49- * instead.
50- */
51- @ Deprecated (forRemoval = true )
52- default Location location () {
53- return getLocationContext ().location ();
54- }
30+ public interface SupportsLocation extends WebDriver , ExecutesMethod {
5531
5632 /**
5733 * Gets the current device's geolocation coordinates.
5834 *
5935 * @return A {@link Location} containing the location information. Throws {@link WebDriverException} if the
6036 * location is not available.
6137 */
62- default io . appium . java_client . Location getLocation () {
38+ default Location getLocation () {
6339 Map <String , Number > result = CommandExecutionHelper .execute (this , MobileCommand .GET_LOCATION );
64- return new io . appium . java_client . Location (
40+ return new Location (
6541 result .get ("latitude" ).doubleValue (),
6642 result .get ("longitude" ).doubleValue (),
6743 Optional .ofNullable (result .get ("altitude" )).map (Number ::doubleValue ).orElse (null )
@@ -72,20 +48,8 @@ default io.appium.java_client.Location getLocation() {
7248 * Sets the current device's geolocation coordinates.
7349 *
7450 * @param location A {@link Location} containing the new location information.
75- * @deprecated This method and whole {@link LocationContext} interface are deprecated, use
76- * {@link #setLocation(io.appium.java_client.Location)} instead.
7751 */
78- @ Deprecated (forRemoval = true )
7952 default void setLocation (Location location ) {
80- getLocationContext ().setLocation (location );
81- }
82-
83- /**
84- * Sets the current device's geolocation coordinates.
85- *
86- * @param location A {@link Location} containing the new location information.
87- */
88- default void setLocation (io .appium .java_client .Location location ) {
8953 var locationParameters = new HashMap <String , Object >();
9054 locationParameters .put ("latitude" , location .getLatitude ());
9155 locationParameters .put ("longitude" , location .getLongitude ());
0 commit comments