@After
 public void tearDown() throws Exception {
   common.takeScreenShotOnFailed(name.getMethodName());
   if (fileHasBeenCreated) {
     FileListView fileListView = new FileListView(driver);
     Actions.deleteElement(CurrentCreatedFile, fileListView, driver);
   }
   driver.removeApp("com.owncloud.android");
   driver.quit();
 }
Example #2
0
  public static void main(String[] args) throws MalformedURLException {
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability("platformName", "android");
    cap.setCapability("app", "e:/example.apk");
    cap.setCapability("unicodeKeyboard", "true");
    cap.setCapability("resetKeyboard", "true");
    //        cap.setCapability("deviceName", "huawei-plk_ul00-W8R0215813002079");
    cap.setCapability("deviceName", "192.168.120.91:5555");

    AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    driver.findElementByAndroidUIAutomator("new UiSelector().text(\"排行榜\")").click();

    //        根据父元素获取同级元素
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().text(\"排行榜\")." + "fromParent(new UiSelector().text(\"应用\"))")
        .click();

    //        获取子元素
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/tab_host\")"
                + ".childSelector(new UiSelector().className(\"android.widget.TextView\").text(\"游戏\"))")
        .click();

    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_image\")")
        .click();

    driver.navigate().back();

    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_box_close\")")
        .click();
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_box_edit\")")
        .sendKeys("腾讯新闻");
    driver
        .findElementByAndroidUIAutomator(
            "new UiSelector().resourceId(\"com.wandoujia.phoenix2:id/search_button\")")
        .click();
    WebElement ele =
        (WebElement)
            driver
                .findElementsByAndroidUIAutomator(
                    "new UiSelector()" + ".className(\"android.widget.TextView\").text(\"安装\")")
                .get(0);
    ele.click();
    driver.openNotifications();
    driver.quit();
  }
 @AfterClass
 public void tearDown() {
   driver.quit();
   Utils.sleep(2);
   Utils.setInputMethod();
 }
  @AfterMethod
  public void tearDown() {

    driver.quit();
  }
 @AfterSuite
 public void quit() {
   driver.quit(); // Quit driver at end.
 }
  @Test
  public void testBeHealthier() throws InterruptedException {
    // Chose Be Healthier Program
    driver.findElement(By.name("Be Healthier")).click();
    // Select Age Button
    driver.findElement(By.id("button_age")).click();
    // Swipe Across Months
    driver.swipe(192, 681, 192, 879, 1000);
    // Swipe Across Days
    driver.swipe(432, 681, 432, 1015, 2000);
    // Swipe Across years
    driver.swipe(672, 681, 672, 1450, 3000);
    // Click OK after selecting date of birth
    driver.findElement(By.id("button1")).click();
    // Select Age Button to get entered birthday
    String dateOfBirth = driver.findElement(By.id("button_age")).getText();
    // Select Male as a sex
    driver.findElement(By.id("radio_male")).click();
    // Click continue to next Screen
    driver.findElement(By.id("button_continue")).click();
    // Enter height
    driver.findElement(By.id("edittext_kg")).sendKeys("172");
    // Click continue to next Screen
    driver.findElement(By.id("button_continue")).click();
    // Enter weight
    driver.findElement(By.id("edittext_kg")).sendKeys("72");
    // Click continue to next Screen
    driver.findElement(By.id("button_continue")).click();
    // Wait until personalizing the app
    Thread.sleep(20000);
    // Skip first meal
    driver.findElement(By.id("skip_button")).click();
    // Wait until getting plan page
    Thread.sleep(5000);
    // Get target calories per day to assert latter
    String targetCaloriesPerDay = driver.findElement(By.id("textview_diary_left_value1")).getText();
    // Press the menu button
    driver
        .findElement(By.id("toolbar"))
        .findElement(By.className("android.widget.ImageButton"))
        .click();
    ;
    Thread.sleep(1000);
    // Press Settings
    driver.findElement(By.name("Settings")).click();
    Thread.sleep(1000);
    // Press Personal Details
    driver.findElement(By.name("Personal Details")).click();
    Thread.sleep(1000);

    // Assert stored values against entered values
    collector.checkThat(
        "Assert Main Screen Target Calories Per Day",
        targetCaloriesPerDay,
        CoreMatchers.equalTo("2250"));
    collector.checkThat(
        "Assert Curren tWeight ",
        driver.findElements(By.id("textview_second")).get(0).getText(),
        CoreMatchers.equalTo("72 kg"));
    collector.checkThat(
        "Assert Calories Per Day ",
        "2250 kcal",
        CoreMatchers.equalTo(driver.findElements(By.id("textview_second")).get(1).getText()));
    collector.checkThat(
        "Assert Height ",
        driver.findElements(By.id("textview_second")).get(2).getText(),
        CoreMatchers.equalTo("172 cm"));
    collector.checkThat(
        "Assert Date Of Birth ",
        driver.findElements(By.id("textview_second")).get(3).getText(),
        CoreMatchers.equalTo(dateOfBirth));
    collector.checkThat(
        "Assert Gender ",
        driver.findElements(By.id("textview_second")).get(4).getText(),
        CoreMatchers.equalTo("Male"));

    // Press the back button to log out
    driver
        .findElement(By.id("action_bar"))
        .findElement(By.className("android.widget.ImageButton"))
        .click();
    driver.scrollTo("Log out").click();
    driver.findElement(By.id("button1")).click();
    // Wait 10 seconds before starting next test case
    Thread.sleep(10000);
    driver.quit();
  }
Example #7
0
 @AfterSuite
 public void tearDownAppium() {
   driver.quit();
 }
  public static void main(String[] args) throws Exception {

    //	stopAppiumServer();

    //	startAppiumServer();

    //		File f=new File("C:\\Mobile Setup\\Jars\\pressie-qa.apk");
    DesiredCapabilities cap = new DesiredCapabilities();
    cap.setCapability("platformName", "Android");
    cap.setCapability("platformVersion", "5.1");
    cap.setCapability("deviceName", "Lenovoa2010");
    //		cap.setCapability("app", f);
    cap.setCapability("appActivity", "jaarwis.signin.ActivitySplash");
    cap.setCapability("appPackage", "jaarwis.pressie");
    AndroidDriver driver = new AndroidDriver<>(new URL("http://localhost:4723/wd/hub"), cap);

    driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
    WebElement findElementByName = driver.findElementByName("Log In");
    findElementByName.click();
    driver.findElementByName("Mobile").click();
    driver.findElementByName("+91").click();
    /*driver.scrollTo("Hong Kong (HK)");
    		driver.findElementByName("Hong Kong (HK)").click();
    */
    //	driver.swipe(100, 100, 100, 1000, 10);

    WebElement element = driver.findElementById("jaarwis.pressie:id/activity_main_container");
    //	String appStrings = driver.getAppStrings();
    Set contextHandles = driver.getContextHandles();
    //	System.out.println(appStrings);
    for (Object object : contextHandles) {
      System.out.println(object.toString());
    }
    ExecuteMethod executeMethod = driver.getExecuteMethod();
    FileDetector fileDetector = driver.getFileDetector();
    Keyboard keyboard = driver.getKeyboard();
    ScreenOrientation orientation = driver.getOrientation();
    URL remoteAddress = driver.getRemoteAddress();
    SessionId sessionId = driver.getSessionId();
    JsonObject settings = driver.getSettings();
    boolean locked = driver.isLocked();
    Location location = driver.location();
    driver.longPressKeyCode(4);
    System.out.println("getExecuteMethod:-" + executeMethod + "FileDetector:-" + fileDetector);
    System.out.println(
        "keyboard:-" + keyboard + "orientation" + orientation + "Remoteadd:-" + remoteAddress);
    System.out.println("sessionId" + sessionId + "settings" + settings);
    System.out.println("locked:-" + locked + "location:-" + location);

    /*driver.findElementById("android.widget.ListView");
    driver.swipe(200, 700, 200, 300, 2000);
    driver.swipe(200, 700, 200, 300, 2000);
    driver.swipe(200, 700, 200, 300, 2000);*/
    // driver.findElementByName("Belgium (BE)").click();
    // driver.swipe(200, 700, 200, 300, 2000);
    // driver.scrollTo("Hong Kong (HK)");
    // scrollto check
    /*WebElement element = driver.findElement(By.name("Element Name"));
    HashMap<String, String> arguments = new HashMap<String, String>();
    arguments.put("Hong Kong", element.getText());
    (JavascriptExecutor)driver.executeScript("mobile: scrollTo", arguments);
    */

    Thread.sleep(10000);

    driver.quit();

    // stopAppiumServer();

  }
Example #9
0
 @AfterMethod(alwaysRun = true)
 public void tearDown() throws Exception {
   driver.quit();
   AppiumServerUtils.getInstance().stopServer();
 }
 @After
 public void tearDown() throws Exception {
   driver.quit();
 }