Java 类org.openqa.selenium.ScreenOrientation 实例源码

项目:AppiumFindByImage    文件:OCRNekoAtsumeTestSuite.java   
@Before
public void setUp() throws Exception {

    //Appium setup for the app
    //needs to be installed on target device before the test
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appPackage", "jp.co.hit_point.nekoatsume");
    capabilities.setCapability("appActivity", "jp.co.hit_point.nekoatsume.GActivity");
    capabilities.setCapability("deviceName", "Android Emulator");
    capabilities.setCapability("platformVersion", "5.0.1");

    driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
    wait = new WebDriverWait(driver, 10);

    //Sikuli settings
    OCR = new OCR(driver);

    //location of screenshots
    File classpathRoot = new File(System.getProperty("user.dir"));
    imgDir = new File(classpathRoot, "src/main/resources");

    //switch to native app + portrait mode
    driver.context("NATIVE_APP");
    driver.rotate(ScreenOrientation.PORTRAIT);
}
项目:riot-automated-tests    文件:RiotMiscTests.java   
/**
 * Open all the legal stuff webiews
 * @throws InterruptedException 
 */
@Test(dataProvider="SearchProvider",dataProviderClass=DataproviderClass.class,groups="1driver_android")
public void openLegalStuffFromPortraitAndLandscapeMode(String items, String expectedTitle) throws InterruptedException{
    RiotHomePageTabObjects homePage=new RiotHomePageTabObjects(appiumFactory.getAndroidDriver1());
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.PORTRAIT);
    homePage.contextMenuButton.click();
    homePage.getItemMenuByName(items).click();
    RiotLegalStuffViewPageObject copyrightPolicyView= new RiotLegalStuffViewPageObject(appiumFactory.getAndroidDriver1());
    Assert.assertTrue(copyrightPolicyView.isPresentTryAndCatch(), "Copyright Policy view isn't open");
    Assert.assertEquals(copyrightPolicyView.secondTitle.getAttribute("name"), expectedTitle);
    copyrightPolicyView.okButton.click();

    //open it again and turn the device in landscape mode : the panel should be still displayed
    homePage.contextMenuButton.click();Thread.sleep(1000);
    homePage.openCopyrightButton.click();
    copyrightPolicyView= new RiotLegalStuffViewPageObject(appiumFactory.getAndroidDriver1());
    driver.rotate(ScreenOrientation.LANDSCAPE);
    Thread.sleep(1500);
    Assert.assertTrue(copyrightPolicyView.isPresentTryAndCatch(), items+" view isn't open");
    //copyrightPolicyView.okButton.click();
    driver.rotate(ScreenOrientation.PORTRAIT);
}
项目:Flashcards    文件:AppiumRule.java   
private void before() throws MalformedURLException {
    String platform = System.getProperty(PLATFORM_KEY);
    if (TextUtils.isEmpty(platform)) {
        platform = PLATFORM_ANDROID;
        //throw new IllegalArgumentException("Platform key (" + PLATFORM_KEY + ") was not set!");
    }
    URL remoteURL = new URL(remoteAddress);
    switch (platform) {
        case PLATFORM_ANDROID:
            driver = AppiumAndroidDriver.create(remoteURL, fullReset);
            break;
        case PLATFORM_IOS:
            driver = AppiumIOSDriver.create(remoteURL, fullReset);
            break;
        default:
            throw new IllegalArgumentException("Unknown platform key :" + platform);
    }
    driver.rotate(ScreenOrientation.PORTRAIT);
    decorator = new AppiumFieldDecorator(driver, timeOutDuration);
    app = new FlashcardsApp(decorator);
}
项目:menggeqa    文件:AppiumDriver.java   
@Override public ScreenOrientation getOrientation() {
    Response response = execute(DriverCommand.GET_SCREEN_ORIENTATION);
    String orientation = response.getValue().toString().toLowerCase();
    if (orientation.equals(ScreenOrientation.LANDSCAPE.value())) {
        return ScreenOrientation.LANDSCAPE;
    } else if (orientation.equals(ScreenOrientation.PORTRAIT.value())) {
        return ScreenOrientation.PORTRAIT;
    } else {
        throw new WebDriverException("Unexpected orientation returned: " + orientation);
    }
}
项目:menggeqa    文件:DefaultAspect.java   
@Before(EXECUTION_ROTATE)
public void beforeRotation(JoinPoint joinPoint) throws Throwable {
    try {
        listener.beforeRotation(driver, (ScreenOrientation) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }

}
项目:menggeqa    文件:DefaultAspect.java   
@After(EXECUTION_ROTATE)
public void afterRotation(JoinPoint joinPoint) throws Throwable {
    try {
        listener.afterRotation(driver, (ScreenOrientation) castArgument(joinPoint, 0));
    } catch (Throwable t) {
        throw getRootCause(t);
    }
}
项目:riot-automated-tests    文件:RiotMiscTests.java   
@Test(groups="1driver_android")
public void switchOrientationMode() throws InterruptedException{
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.LANDSCAPE);//Thread.sleep(2000);
    (new WebDriverWait(appiumFactory.getAndroidDriver1(), 15)).until(ExpectedConditions.presenceOfElementLocated(By.className("android.widget.FrameLayout")));
    scrollWindowDown();
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.PORTRAIT);//Thread.sleep(2000);
    (new WebDriverWait(appiumFactory.getAndroidDriver1(), 15)).until(ExpectedConditions.presenceOfElementLocated(By.className("android.widget.FrameLayout")));
    scrollWindowDown();
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.LANDSCAPE);//Thread.sleep(2000);
    (new WebDriverWait(appiumFactory.getAndroidDriver1(), 15)).until(ExpectedConditions.presenceOfElementLocated(By.className("android.widget.FrameLayout")));
    scrollWindowDown();
}
项目:Flashcards    文件:TestUtils.java   
public static void rotateSafely(AppiumDriver<?> driver, ScreenOrientation orientation) {
    try {
        driver.rotate(orientation);
    } catch (Exception ignored) {
        // For some reason, even though screen is rotated it's reported as error
    }
}
项目:AppiumSauce    文件:NativeAndroidTest.java   
@Test
public void setOrientationToLandscapeTest() {
    wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("android:id/action_bar_title"))));
    ((AndroidDriver<WebElement>)driver).startActivity("io.appium.android.apis", ".app.ScreenOrientation");

    setOrientation("LANDSCAPE");

    ScreenOrientation currentOrientation = driver.getOrientation();
    assertThat(currentOrientation, is(ScreenOrientation.LANDSCAPE));
}
项目:AppiumSauce    文件:NativeAndroidTest.java   
@Test
public void setOrientationToPortraitTest() {
    wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.id("android:id/action_bar_title"))));
    ((AndroidDriver<WebElement>)driver).startActivity("io.appium.android.apis", ".app.ScreenOrientation");
    setOrientation("PORTRAIT");

    ScreenOrientation currentOrientation = driver.getOrientation();
    assertThat(currentOrientation, is(ScreenOrientation.PORTRAIT));
}
项目:seletest    文件:AppiumDriverController.java   
@Override
@Monitor
@RetryFailure(retryCount=3)
public AppiumDriverController rotate(ScreenOrientation e) {
    webDriver().rotate(e);
    return this;
}
项目:selendroid    文件:OrientationTest.java   
@Test
public void shouldRotate() throws Exception {
  openWebdriverTestPage(HtmlTestData.ABOUT_BLANK);
  Assert.assertEquals(ScreenOrientation.PORTRAIT, driver().getOrientation());
  driver().rotate(ScreenOrientation.LANDSCAPE);
  Assert.assertEquals(ScreenOrientation.LANDSCAPE, driver().getOrientation());
  driver().rotate(ScreenOrientation.PORTRAIT);
  Assert.assertEquals(ScreenOrientation.PORTRAIT, driver().getOrientation());
}
项目:bobcat    文件:WebDriverWrapper.java   
@Override
public ScreenOrientation getOrientation() {
  return ((Rotatable) super.getWrappedDriver()).getOrientation();
}
项目:bobcat    文件:WebDriverWrapper.java   
@Override
public void rotate(ScreenOrientation screenOrientation) {
  ((Rotatable) super.getWrappedDriver()).rotate(screenOrientation);
}
项目:xframium-java    文件:AbstractRotateGesture.java   
public void setParameters( Object[] parameterArray )
{
    setOrientation( (ScreenOrientation) parameterArray[ 0 ] );
}
项目:menggeqa    文件:AppiumDriver.java   
@Override public void rotate(ScreenOrientation orientation) {
    execute(DriverCommand.SET_SCREEN_ORIENTATION,
        ImmutableMap.of("orientation", orientation.value().toUpperCase()));
}
项目:menggeqa    文件:DefaultListener.java   
@Override public void beforeRotation(WebDriver driver, ScreenOrientation orientation) {
    ((RotationEventListener) dispatcher).beforeRotation(driver, orientation);
}
项目:menggeqa    文件:DefaultListener.java   
@Override public void afterRotation(WebDriver driver, ScreenOrientation orientation) {
    ((RotationEventListener) dispatcher).afterRotation(driver, orientation);
}
项目:riot-automated-tests    文件:RiotSearchTests.java   
/**
 * Search in ROOMS and MESSAGES tab in search from recent.</br> 
 * Validate the issue https://github.com/vector-im/riot-android/issues/934 too. </br>
 * 1. Create a room with a random name.</br>
 * 2. Post a random msg within</br>
 * 3. From the rooms list hit the search button</br>
 * 4. Search in ROOMS tab the random name given in step1</br>
 * Check that the room previously created shown up</br>
 * Check that the room previously created doesn't appears in browse directory </br>
 * 5. Search in MESSAGES tab the random msg given in step2</br>
 * Check that the random msg is shown up.</br>
 * 6. Turn the device in landscape mode, then portrait</br>
 * Check that the search result is still displayed https://github.com/vector-im/riot-android/issues/934</br>
 * @throws InterruptedException 
 */
@Test(groups={"1driver_android","1checkuser_and_contact_permission",}, priority=0,description="test on the search from the rooms list")
public void globalSearchRoomsAndMessages() throws InterruptedException{
    int randInt1 = 1 + (int)(Math.random() * ((10000 - 1) + 1));
    int randInt2 = 1 + (int)(Math.random() * ((10000 - 1) + 1));
    String randomRoomName=(new StringBuilder("room_search").append(randInt1)).toString();
    String randomMsg=(new StringBuilder("msg_search").append(randInt2)).toString();

    //1. Create a room with a random name.
    RiotHomePageTabObjects homePage=new RiotHomePageTabObjects(appiumFactory.getAndroidDriver1());
    RiotRoomPageObjects newRoom= homePage.createRoom();
    newRoom.changeRoomName(randomRoomName);

    //2. Post a random msg within
    newRoom.sendAMessage(randomMsg);

    //3. From the rooms list hit the search button
    newRoom.menuBackButton.click();
    homePage.openGlobalSearchLayout();

    //4. Search in ROOMS tab the random name given in step1
    RiotUnifiedSearchPageObjects searchInRoomsList = new RiotUnifiedSearchPageObjects(appiumFactory.getAndroidDriver1());
    searchInRoomsList.roomsTab.click();
    searchInRoomsList.launchASearch(randomRoomName,true);

    //Check that only 1 result show up and Check that the room previously created shows up
    Assert.assertEquals(searchInRoomsList.getRoomsLayout(true).size(), 1);
    searchInRoomsList.checkRoomItemFromResult(1,randomRoomName,randomMsg);
    //Check that the room previously created doesn't appears in browse directory
    waitUntilPropertyIsSet(searchInRoomsList.getBrowseDirectory().findElementById("im.vector.alpha:id/roomSummaryAdapter_roomMessage"), "text", "Searching directory..", false, 20);
    Assert.assertEquals(searchInRoomsList.getBrowseDirectory().findElementById("im.vector.alpha:id/roomSummaryAdapter_roomMessage").getText(), "0 room found for "+randomRoomName);
    searchInRoomsList.clearSearchButton.click();

    //5. Search in MESSAGES tab the random msg given in step2
    searchInRoomsList.messagesTab.click();
    searchInRoomsList.launchASearch(randomMsg,true);
    //Check that only 1 result shown up and Check that the random msg is shown up.
    Assert.assertEquals(searchInRoomsList.listMessagesLinearLayouts.size(), 1);
    searchInRoomsList.checkMessageItemFromResult(0, randomRoomName,null,randomMsg);

    //6. Turn the device in landscape mode, then portrait
    searchInRoomsList.searchEditText.click();
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.LANDSCAPE);
    Thread.sleep(1500);
    appiumFactory.getAndroidDriver1().rotate(ScreenOrientation.PORTRAIT);
    //Check that the search result is still displayed https://github.com/vector-im/riot-android/issues/934
    Assert.assertEquals(searchInRoomsList.listMessagesLinearLayouts.size(), 1);
    searchInRoomsList.checkMessageItemFromResult(0, randomRoomName,null,randomMsg);

    //teardown : leave room
    searchInRoomsList.menuBackButton.click();
    homePage.leaveRoom(randomRoomName);
    Thread.sleep(500);
}
项目:grid-refactor-remote-server    文件:Rotate.java   
public void setJsonParameters(Map<String, Object> allParameters) throws Exception {
  orientation = ScreenOrientation.valueOf((String) allParameters.get("orientation"));
}
项目:grid-refactor-remote-server    文件:GetScreenOrientation.java   
@Override
public ScreenOrientation call() throws Exception {
  return ((Rotatable) getUnwrappedDriver()).getOrientation();
}
项目:seletest    文件:AppiumDriverController.java   
@Override
@Monitor
@RetryFailure(retryCount=3)
public ScreenOrientation getscreen() {
    return webDriver().getOrientation();
}
项目:selendroid    文件:SelendroidDriver.java   
@Override
public void rotate(ScreenOrientation orientation) {
  execute(org.openqa.selenium.remote.DriverCommand.SET_SCREEN_ORIENTATION,
      ImmutableMap.of("orientation", orientation));
}
项目:selendroid    文件:SelendroidDriver.java   
@Override
public ScreenOrientation getOrientation() {
  return ScreenOrientation.valueOf((String) execute(
      org.openqa.selenium.remote.DriverCommand.GET_SCREEN_ORIENTATION).getValue());
}
项目:xframium-java    文件:AbstractRotateGesture.java   
/**
 * Gets the orientation.
 *
 * @return the orientation
 */
public ScreenOrientation getOrientation()
{
    return sOrientation;
}
项目:xframium-java    文件:AbstractRotateGesture.java   
/**
 * Sets the orientation.
 *
 * @param sOrientation the new orientation
 */
public void setOrientation( ScreenOrientation sOrientation )
{
    this.sOrientation = sOrientation;
}
项目:xframium-java    文件:GestureManager.java   
/**
 * Creates the rotate.
 *
 * @param sOrientation
 *            the s orientation
 * @return the gesture
 */
public Gesture createRotate( String xFID, ScreenOrientation sOrientation )
{
    return gestureFactory.createGesture( GestureType.ROTATE, new Object[] { sOrientation } );
}
项目:menggeqa    文件:RotationEventListener.java   
/**
 * Called before {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}.
 *
 * @param driver WebDriver
 * @param orientation the desired screen orientation
 */
void beforeRotation(WebDriver driver, ScreenOrientation orientation);
项目:menggeqa    文件:RotationEventListener.java   
/**
 * Called after {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}.
 *
 * @param driver WebDriver
 * @param orientation the desired screen orientation
 */
void afterRotation(WebDriver driver, ScreenOrientation orientation);
项目:seletest    文件:AppiumController.java   
/**
 * rotate screen of mobile device
 * @param e Screenrientation
 */
<T> T rotate(ScreenOrientation e);
项目:seletest    文件:AppiumController.java   
/**
 * gets the screen orientation
 * @return ScreenOrientation
 */
ScreenOrientation getscreen();