@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); }
/** * 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); }
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); }
@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); } }
@Before(EXECUTION_ROTATE) public void beforeRotation(JoinPoint joinPoint) throws Throwable { try { listener.beforeRotation(driver, (ScreenOrientation) castArgument(joinPoint, 0)); } catch (Throwable t) { throw getRootCause(t); } }
@After(EXECUTION_ROTATE) public void afterRotation(JoinPoint joinPoint) throws Throwable { try { listener.afterRotation(driver, (ScreenOrientation) castArgument(joinPoint, 0)); } catch (Throwable t) { throw getRootCause(t); } }
@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(); }
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 } }
@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)); }
@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)); }
@Override @Monitor @RetryFailure(retryCount=3) public AppiumDriverController rotate(ScreenOrientation e) { webDriver().rotate(e); return this; }
@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()); }
@Override public ScreenOrientation getOrientation() { return ((Rotatable) super.getWrappedDriver()).getOrientation(); }
@Override public void rotate(ScreenOrientation screenOrientation) { ((Rotatable) super.getWrappedDriver()).rotate(screenOrientation); }
public void setParameters( Object[] parameterArray ) { setOrientation( (ScreenOrientation) parameterArray[ 0 ] ); }
@Override public void rotate(ScreenOrientation orientation) { execute(DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation", orientation.value().toUpperCase())); }
@Override public void beforeRotation(WebDriver driver, ScreenOrientation orientation) { ((RotationEventListener) dispatcher).beforeRotation(driver, orientation); }
@Override public void afterRotation(WebDriver driver, ScreenOrientation orientation) { ((RotationEventListener) dispatcher).afterRotation(driver, orientation); }
/** * 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); }
public void setJsonParameters(Map<String, Object> allParameters) throws Exception { orientation = ScreenOrientation.valueOf((String) allParameters.get("orientation")); }
@Override public ScreenOrientation call() throws Exception { return ((Rotatable) getUnwrappedDriver()).getOrientation(); }
@Override @Monitor @RetryFailure(retryCount=3) public ScreenOrientation getscreen() { return webDriver().getOrientation(); }
@Override public void rotate(ScreenOrientation orientation) { execute(org.openqa.selenium.remote.DriverCommand.SET_SCREEN_ORIENTATION, ImmutableMap.of("orientation", orientation)); }
@Override public ScreenOrientation getOrientation() { return ScreenOrientation.valueOf((String) execute( org.openqa.selenium.remote.DriverCommand.GET_SCREEN_ORIENTATION).getValue()); }
/** * Gets the orientation. * * @return the orientation */ public ScreenOrientation getOrientation() { return sOrientation; }
/** * Sets the orientation. * * @param sOrientation the new orientation */ public void setOrientation( ScreenOrientation sOrientation ) { this.sOrientation = sOrientation; }
/** * 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 } ); }
/** * Called before {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}. * * @param driver WebDriver * @param orientation the desired screen orientation */ void beforeRotation(WebDriver driver, ScreenOrientation orientation);
/** * Called after {@link org.openqa.selenium.Rotatable#rotate(ScreenOrientation)}. * * @param driver WebDriver * @param orientation the desired screen orientation */ void afterRotation(WebDriver driver, ScreenOrientation orientation);
/** * rotate screen of mobile device * @param e Screenrientation */ <T> T rotate(ScreenOrientation e);
/** * gets the screen orientation * @return ScreenOrientation */ ScreenOrientation getscreen();