org.openqa.selenium.DeviceRotation Java Examples

The following examples show how to use org.openqa.selenium.DeviceRotation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AppiumDriver.java    From java-client with Apache License 2.0 5 votes vote down vote up
@Override
public DeviceRotation rotation() {
    Response response = execute(DriverCommand.GET_SCREEN_ROTATION);
    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;
}
 
Example #2
Source File: UIAutomator2Test.java    From java-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testLandscapeRightRotation() {
    new WebDriverWait(driver, 20).until(ExpectedConditions
            .elementToBeClickable(driver.findElementById("android:id/content")
                    .findElement(MobileBy.AccessibilityId("Graphics"))));
    DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 90);
    driver.rotate(landscapeRightRotation);
    assertEquals(driver.rotation(), landscapeRightRotation);
}
 
Example #3
Source File: UIAutomator2Test.java    From java-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testLandscapeLeftRotation() {
    new WebDriverWait(driver, 20).until(ExpectedConditions
            .elementToBeClickable(driver.findElementById("android:id/content")
                    .findElement(MobileBy.AccessibilityId("Graphics"))));
    DeviceRotation landscapeLeftRotation = new DeviceRotation(0, 0, 270);
    driver.rotate(landscapeLeftRotation);
    assertEquals(driver.rotation(), landscapeLeftRotation);
}
 
Example #4
Source File: UIAutomator2Test.java    From java-client with Apache License 2.0 5 votes vote down vote up
@Test
public void testPortraitUpsideDown() {
    new WebDriverWait(driver, 20).until(ExpectedConditions
            .elementToBeClickable(driver.findElementById("android:id/content")
                    .findElement(MobileBy.AccessibilityId("Graphics"))));
    DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 180);
    driver.rotate(landscapeRightRotation);
    assertEquals(driver.rotation(), landscapeRightRotation);
}
 
Example #5
Source File: RemoteRotatable.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Override
public DeviceRotation rotation() {
  Object result = executeMethod.execute(DriverCommand.GET_SCREEN_ROTATION, null);
  if (!(result instanceof Map)) {
    throw new IllegalStateException("Unexpected return value: " + result);
  }

  @SuppressWarnings("unchecked") Map<String, Number> raw = (Map<String, Number>) result;
  return new DeviceRotation(raw);
}
 
Example #6
Source File: WebDriverWrapper.java    From bobcat with Apache License 2.0 4 votes vote down vote up
@Override
public void rotate(DeviceRotation deviceRotation) {
  ((Rotatable) super.getWrappedDriver()).rotate(deviceRotation);
}
 
Example #7
Source File: WebDriverWrapper.java    From bobcat with Apache License 2.0 4 votes vote down vote up
@Override
public DeviceRotation rotation() {
  return ((Rotatable) super.getWrappedDriver()).rotation();
}
 
Example #8
Source File: AppiumDriver.java    From java-client with Apache License 2.0 4 votes vote down vote up
@Override
public void rotate(DeviceRotation rotation) {
    execute(DriverCommand.SET_SCREEN_ROTATION, rotation.parameters());
}
 
Example #9
Source File: UIAutomator2Test.java    From java-client with Apache License 2.0 4 votes vote down vote up
@After
public void afterMethod() {
    driver.rotate(new DeviceRotation(0, 0, 0));
}
 
Example #10
Source File: EmptyWebDriver.java    From java-client with Apache License 2.0 4 votes vote down vote up
@Override public void rotate(DeviceRotation rotation) {
    //The rotation does nothing there
}
 
Example #11
Source File: EmptyWebDriver.java    From java-client with Apache License 2.0 4 votes vote down vote up
@Override public DeviceRotation rotation() {
    return null;
}
 
Example #12
Source File: RotationTest.java    From java-client with Apache License 2.0 4 votes vote down vote up
@After public void afterMethod() {
    driver.rotate(new DeviceRotation(0, 0, 0));
}
 
Example #13
Source File: RotationTest.java    From java-client with Apache License 2.0 4 votes vote down vote up
@Test public void testLandscapeRightRotation() {
    DeviceRotation landscapeRightRotation = new DeviceRotation(0, 0, 90);
    driver.rotate(landscapeRightRotation);
    assertEquals(driver.rotation(), landscapeRightRotation);
}
 
Example #14
Source File: RotationTest.java    From java-client with Apache License 2.0 4 votes vote down vote up
@Test public void testLandscapeLeftRotation() {
    DeviceRotation landscapeLeftRotation = new DeviceRotation(0, 0, 270);
    driver.rotate(landscapeLeftRotation);
    assertEquals(driver.rotation(), landscapeLeftRotation);
}
 
Example #15
Source File: RemoteRotatable.java    From selenium with Apache License 2.0 4 votes vote down vote up
@Override
public void rotate(DeviceRotation rotation) {
  executeMethod.execute(DriverCommand.SET_SCREEN_ORIENTATION, rotation.parameters());
}