Skip to content

Commit c9db0ba

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

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
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: 18 additions & 1 deletion
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;
@@ -630,7 +631,23 @@ 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+
DeviceRotation deviceRotation = new DeviceRotation((Map<String, Integer>)response.getValue());
645+
if (deviceRotation.getX() < 0 || deviceRotation.getY() < 0 || deviceRotation.getZ() < 0) {
646+
throw new WebDriverException("Unexpected orientation returned: " + deviceRotation);
647+
}
648+
return deviceRotation;
649+
}
650+
634651
@Override public Location location() {
635652
return locationContext.location();
636653
}

0 commit comments

Comments
 (0)