Skip to content

Commit e3a034f

Browse files
rafael.chavezrafe-g
authored andcommitted
Rotation support.
1 parent 2face58 commit e3a034f

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

google-style.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,4 @@
219219
</module>
220220
<module name="CommentsIndentation"/>
221221
</module>
222-
</module>
222+
</module>

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
<artifactId>gson</artifactId>
2828
<version>2.6.2</version>
2929
</dependency>
30+
<dependency>
31+
<groupId>org.seleniumhq.selenium</groupId>
32+
<artifactId>selenium-api</artifactId>
33+
<version>2.53.0</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.seleniumhq.selenium</groupId>
37+
<artifactId>selenium-chrome-driver</artifactId>
38+
<version>2.53.0</version>
39+
</dependency>
3040
<dependency>
3141
<groupId>org.seleniumhq.selenium</groupId>
3242
<artifactId>selenium-java</artifactId>
@@ -38,6 +48,16 @@
3848
</exclusion>
3949
</exclusions>
4050
</dependency>
51+
<dependency>
52+
<groupId>org.seleniumhq.selenium</groupId>
53+
<artifactId>selenium-remote-driver</artifactId>
54+
<version>2.53.0</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.seleniumhq.selenium</groupId>
58+
<artifactId>selenium-support</artifactId>
59+
<version>2.53.0</version>
60+
</dependency>
4161
<dependency>
4262
<groupId>junit</groupId>
4363
<artifactId>junit</artifactId>

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.openqa.selenium.Dimension;
5353
import org.openqa.selenium.Point;
5454
import org.openqa.selenium.ScreenOrientation;
55+
import org.openqa.selenium.DeviceRotation;
5556
import org.openqa.selenium.WebDriver;
5657
import org.openqa.selenium.WebDriverException;
5758
import org.openqa.selenium.WebElement;
@@ -225,7 +226,7 @@ private static CommandInfo deleteC(String url) {
225226
@Override public List<T> findElements(By by) {
226227
return super.findElements(by);
227228
}
228-
229+
229230
@Override public List<T> findElements(String by, String using) {
230231
return super.findElements(by, using);
231232
}
@@ -630,7 +631,24 @@ protected void setSetting(AppiumSetting setting, Object value) {
630631
throw new WebDriverException("Unexpected orientation returned: " + orientation);
631632
}
632633
}
633-
634+
635+
@Override
636+
public void rotate(DeviceRotation rotation) {
637+
execute(DriverCommand.SET_SCREEN_ROTATION,
638+
ImmutableMap.of("orientation", rotation.parameters()));
639+
}
640+
641+
@Override
642+
public DeviceRotation rotation() {
643+
Response response = execute(DriverCommand.GET_SCREEN_ROTATION);
644+
Map<String, Integer> map = null;// = response.readEntity(Map.class);
645+
DeviceRotation deviceRotation = new DeviceRotation(map);
646+
if (deviceRotation.getX() < 0 || deviceRotation.getY() < 0 || deviceRotation.getZ() < 0) {
647+
throw new WebDriverException("Unexpected orientation returned: " + deviceRotation);
648+
}
649+
return deviceRotation;
650+
}
651+
634652
@Override public Location location() {
635653
return locationContext.location();
636654
}

0 commit comments

Comments
 (0)