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

Rotation support. #439

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion google-style.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@
</module>
<module name="CommentsIndentation"/>
</module>
</module>
</module>
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>2.53.0</version>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this?

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
Expand All @@ -38,6 +48,16 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
22 changes: 19 additions & 3 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.DeviceRotation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -225,11 +226,11 @@ private static CommandInfo deleteC(String url) {
@Override public List<T> findElements(By by) {
return super.findElements(by);
}

@Override public List<T> findElements(String by, String using) {
return super.findElements(by, using);
}

@Override public List<T> findElementsById(String id) {
return super.findElementsById(id);
}
Expand Down Expand Up @@ -630,7 +631,22 @@ protected void setSetting(AppiumSetting setting, Object value) {
throw new WebDriverException("Unexpected orientation returned: " + orientation);
}
}


@Override
public void rotate(DeviceRotation rotation) {
execute(DriverCommand.SET_SCREEN_ROTATION, rotation.parameters());
}

@Override
public DeviceRotation rotation() {
Response response = execute(DriverCommand.GET_SCREEN_ROTATION);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry let me update this, forgot to commit this part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable is being used.

DeviceRotation deviceRotation = new DeviceRotation((Map<String, Number>)response.getValue());
if (deviceRotation.getX() < 0 || deviceRotation.getY() < 0 || deviceRotation.getZ() < 0) {
throw new WebDriverException("Unexpected orientation returned: " + deviceRotation);
}
return deviceRotation;
}

@Override public Location location() {
return locationContext.location();
}
Expand Down