Skip to content

Commit c485fa5

Browse files
committed
Merge branch 'master' of https://github.com/appium/java-client
2 parents f103caf + fd3cce8 commit c485fa5

7 files changed

Lines changed: 77 additions & 13 deletions

File tree

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Depends upon the Selenium Java client library, available [here](http://docs.sele
1111
<dependency>
1212
<groupId>io.appium</groupId>
1313
<artifactId>java-client</artifactId>
14-
<version>1.5.0</version>
14+
<version>1.6.1</version>
1515
</dependency>
1616
```
1717

@@ -61,6 +61,13 @@ Locators:
6161
- findElementsByAndroidUIAutomator()
6262

6363
##Changelog##
64+
*1.6.1*
65+
- Fixed the logic for checking connection status on NetworkConnectionSetting objects
66+
67+
*1.6.0*
68+
- Added @findBy annotations. Explanation here: https://github.com/appium/java-client/pull/68 Thanks to TikhomirovSergey
69+
- Appium Driver now implements LocationContext interface, so setLocation() works for setting GPS coordinates
70+
6471
*1.5.0*
6572
- Added MobileCapabilityType enums for desired capabilities
6673
- `findElement` and `findElements` return MobileElement objects (still need to be casted, but no longer instantiated)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>io.appium</groupId>
77
<artifactId>java-client</artifactId>
8-
<version>1.5.0</version>
8+
<version>1.6.1</version>
99
<dependencies>
1010
<dependency>
1111
<groupId>com.google.code.gson</groupId>

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
import com.google.common.collect.ImmutableMap;
2222
import io.appium.java_client.internal.JsonToMobileElementConverter;
2323
import org.openqa.selenium.*;
24+
import org.openqa.selenium.html5.Location;
25+
import org.openqa.selenium.html5.LocationContext;
2426
import org.openqa.selenium.remote.*;
27+
import org.openqa.selenium.remote.html5.RemoteLocationContext;
2528

2629
import javax.xml.bind.DatatypeConverter;
2730
import java.net.URL;
@@ -33,19 +36,23 @@
3336
import static io.appium.java_client.MobileCommand.*;
3437

3538
public class AppiumDriver extends RemoteWebDriver implements MobileDriver, ContextAware, Rotatable, FindsByIosUIAutomation,
36-
FindsByAndroidUIAutomator, FindsByAccessibilityId {
39+
FindsByAndroidUIAutomator, FindsByAccessibilityId, LocationContext {
3740

3841
private final static ErrorHandler errorHandler = new ErrorHandler(new ErrorCodesMobile(), true);
3942
private URL remoteAddress;
4043
private ComplexFind complexFind;
44+
private RemoteLocationContext locationContext;
45+
private ExecuteMethod executeMethod;
4146

4247
public AppiumDriver(URL remoteAddress, Capabilities desiredCapabilities){
4348

4449
super(remoteAddress, desiredCapabilities);
4550
this.setElementConverter(new JsonToMobileElementConverter(this));
4651

52+
this.executeMethod = new AppiumExecutionMethod(this);
4753
this.remoteAddress = remoteAddress;
4854
complexFind = new ComplexFind(this);
55+
locationContext = new RemoteLocationContext(executeMethod);
4956

5057
ImmutableMap.Builder<String, CommandInfo> builder = ImmutableMap.builder();
5158
builder
@@ -93,6 +100,10 @@ protected Response execute(String command) {
93100
return execute(command, ImmutableMap.<String, Object>of());
94101
}
95102

103+
@Override
104+
public ExecuteMethod getExecuteMethod() {
105+
return executeMethod;
106+
}
96107

97108
/**
98109
* Reset the currently running app for this session
@@ -626,6 +637,16 @@ public List<WebElement> findElementsByAccessibilityId(String using) {
626637
return findElements("accessibility id", using);
627638
}
628639

640+
@Override
641+
public Location location() {
642+
return locationContext.location();
643+
}
644+
645+
@Override
646+
public void setLocation(Location location) {
647+
locationContext.setLocation(location);
648+
}
649+
629650
private TouchAction createTap(WebElement element, int duration) {
630651
TouchAction tap = new TouchAction(this);
631652
return tap.press(element).waitAction(duration).release();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.appium.java_client;
2+
3+
import com.google.common.collect.ImmutableMap;
4+
import org.openqa.selenium.remote.ExecuteMethod;
5+
import org.openqa.selenium.remote.Response;
6+
7+
import java.util.Map;
8+
9+
public class AppiumExecutionMethod implements ExecuteMethod {
10+
private final AppiumDriver driver;
11+
12+
public AppiumExecutionMethod(AppiumDriver driver) {
13+
this.driver = driver;
14+
}
15+
16+
public Object execute(String commandName, Map<String, ?> parameters) {
17+
Response response;
18+
19+
if (parameters == null || parameters.isEmpty()) {
20+
response = driver.execute(commandName, ImmutableMap.<String, Object>of());
21+
} else {
22+
response = driver.execute(commandName, parameters);
23+
}
24+
25+
return response.getValue();
26+
}
27+
}

src/main/java/io/appium/java_client/NetworkConnectionSetting.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public NetworkConnectionSetting(int bitmask) {
3434
value = bitmask;
3535
}
3636

37-
public boolean airplaneModeEnabled() { return (value & airplaneMode) == 1; }
37+
public boolean airplaneModeEnabled() { return (value & airplaneMode) != 0; }
3838

39-
public boolean wifiEnabled() { return (value & wifi) == 1; }
39+
public boolean wifiEnabled() { return (value & wifi) != 0; }
4040

41-
public boolean dataEnabled() { return (value & data) == 1; }
41+
public boolean dataEnabled() { return (value & data) != 0; }
4242

4343
public void setAirplaneMode(boolean enable) {
4444
if (enable) {

src/test/java/io/appium/java_client/AndroidGestureTest.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@
1717

1818
package io.appium.java_client;
1919

20-
import static org.junit.Assert.*;
2120
import io.appium.java_client.remote.MobileCapabilityType;
22-
23-
import java.io.File;
24-
import java.net.URL;
25-
2621
import org.junit.After;
2722
import org.junit.Before;
2823
import org.junit.Test;
2924
import org.openqa.selenium.By;
3025
import org.openqa.selenium.WebElement;
3126
import org.openqa.selenium.remote.DesiredCapabilities;
3227

28+
import java.io.File;
29+
import java.net.URL;
30+
31+
import static org.junit.Assert.assertEquals;
32+
import static org.junit.Assert.assertNotEquals;
33+
3334
/**
3435
* Test Mobile Driver features
3536
*/
@@ -83,7 +84,8 @@ public void dragNDropTest() {
8384
}
8485

8586
@Test
86-
public void TapSingleFingerTest() {
87-
driver.tap(1,100,200,1000);
87+
public void TapSingleFingerTest() throws InterruptedException {
88+
Thread.sleep(2500);
89+
driver.tap(1,200,300,1000);
8890
}
8991
}

src/test/java/io/appium/java_client/MobileDriverIOSTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.junit.Before;
2424
import org.junit.Test;
2525
import org.openqa.selenium.ScreenOrientation;
26+
import org.openqa.selenium.html5.Location;
2627
import org.openqa.selenium.remote.DesiredCapabilities;
2728

2829
import java.io.File;
@@ -130,4 +131,10 @@ public void orientationTest() {
130131
assertEquals(ScreenOrientation.LANDSCAPE, driver.getOrientation());
131132
}
132133

134+
@Test
135+
public void geolocationTest() {
136+
Location location = new Location(45, 45, 100);
137+
driver.setLocation(location);
138+
}
139+
133140
}

0 commit comments

Comments
 (0)