/**
  * 点击搜索框后,输入搜索关键词进行搜索
  *
  * @throws UiObjectNotFoundException
  */
 public void setSearchWord() throws UiObjectNotFoundException {
   // 点击搜索框
   UiObject textV = new UiObject(new UiSelector().resourceId("com.mappn.gfan:id/tv_search"));
   textV.click();
   // 判断搜索框是否存在-输入QQ搜索
   UiObject textVChild =
       new UiObject(new UiSelector().resourceId("com.mappn.gfan:id/top_search_container"));
   Assert.assertEquals(true, textVChild.exists());
   textVChild.setText("QQ");
   sleep(1000);
   // 获取搜索关键字列表
   UiObject listViewOb =
       new UiObject(new UiSelector().resourceId("com.mappn.gfan:id/baselistview"));
   // Assert.assertEquals(0, listViewOb.getChildCount());
   // 点击列表第一个搜索关键字
   UiObject childOb = listViewOb.getChild(new UiSelector().index(6));
   // childOb.click();
   Assert.assertEquals(true, childOb.exists());
   if (childOb.exists()) {
     childOb.clickAndWaitForNewWindow();
   } else {
     UiObject selectButton =
         new UiObject(new UiSelector().resourceId("com.mappn.gfan:id/top_search_container"));
     selectButton.clickAndWaitForNewWindow();
   }
 }
  public void testLogin() throws UiObjectNotFoundException {
    UiObject validation = new UiObject(new UiSelector().packageName("com.jingdong.app.mall"));
    assertTrue(validation.waitForExists(5000));

    UiScrollable pager =
        new UiScrollable(new UiSelector().resourceId("com.jingdong.app.mall:id/viewpager"));
    if (pager.waitForExists(3000)) {
      pager.setAsHorizontalList();
      pager.scrollToEnd(4);

      UiObject startup =
          new UiObject(new UiSelector().resourceId("com.jingdong.app.mall:id/btn_experience"));
      startup.click();
    }

    UiObject my =
        new UiObject(
            new UiSelector()
                .resourceId("com.jingdong.app.mall:id/bottomMenu")
                .childSelector(new UiSelector().className(RadioButton.class).index(4)));
    my.waitForExists(8000);
    my.click();
    my.click();

    UiObject login =
        new UiObject(
            new UiSelector().resourceId("com.jingdong.app.mall:id/personal_click_for_login"));
    login.clickAndWaitForNewWindow();

    UiObject username =
        new UiObject(new UiSelector().resourceId("com.jingdong.app.mall:id/login_input_name"));
    username.setText("18824238317");
    UiObject password =
        new UiObject(new UiSelector().resourceId("com.jingdong.app.mall:id/login_input_password"));
    password.setText("ztemt123");
    UiObject loginbtn =
        new UiObject(new UiSelector().resourceId("com.jingdong.app.mall:id/login_comfirm_button"));
    loginbtn.click();
  }
Exemple #3
0
 public void searchVideo(String videoSearchString) throws UiObjectNotFoundException {
   UiObject searchVideoButton =
       new UiObject(
           new UiSelector()
               .className("android.widget.TextView")
               .resourceId("com.ted.android:id/menu_search"));
   searchVideoButton.clickAndWaitForNewWindow();
   UiObject textBox =
       new UiObject(
           new UiSelector()
               .className("android.widget.EditText")
               .resourceId("android:id/search_src_text"));
   textBox.setText(videoSearchString);
   UiDevice device = UiDevice.getInstance();
   device.pressEnter();
 }
  public void testLogin() throws UiObjectNotFoundException {
    UiObject validation = new UiObject(new UiSelector().packageName("com.chaozh.iReader"));
    assertTrue(validation.waitForExists(5000));

    UiObject confirm =
        new UiObject(
            new UiSelector().resourceId("com.chaozh.iReader:id/defualt_compoundButton").text("确定"));
    if (confirm.waitForExists(3000)) {
      confirm.click();
    }

    UiScrollable pager =
        new UiScrollable(new UiSelector().resourceId("com.chaozh.iReader:id/viewpager"));
    if (pager.exists()) {
      pager.setAsHorizontalList();
      pager.scrollToEnd(1);

      UiObject startup =
          new UiObject(new UiSelector().resourceId("com.chaozh.iReader:id/btn_start"));
      startup.click();
    }

    UiObject center =
        new UiObject(new UiSelector().resourceId("com.chaozh.iReader:id/bookShelf_head_Center_ID"));
    center.click();
    center.click();

    UiObject left =
        new UiObject(new UiSelector().resourceId("com.chaozh.iReader:id/bookShelf_head_left_ID"));
    left.click();

    UiObject login =
        new UiObject(new UiSelector().resourceId("com.chaozh.iReader:id/person_longin"));
    login.clickAndWaitForNewWindow();

    UiObject ireader =
        new UiObject(
            new UiSelector()
                .resourceId("com.chaozh.iReader:id/account_main_thirdlogin")
                .childSelector(
                    new UiSelector()
                        .index(0)
                        .childSelector(
                            new UiSelector()
                                .index(1)
                                .childSelector(
                                    new UiSelector()
                                        .index(1)
                                        .childSelector(new UiSelector().index(0))))));
    ireader.clickAndWaitForNewWindow();

    UiObject username =
        new UiObject(
            new UiSelector()
                .resourceId("com.chaozh.iReader:id/account_block_zhangyueid_login_name"));
    username.setText("18824238317");
    UiObject password =
        new UiObject(
            new UiSelector()
                .resourceId("com.chaozh.iReader:id/account_block_zhangyueid_login_password"));
    password.setText("ztemt123");
    UiObject loginbtn =
        new UiObject(
            new UiSelector()
                .resourceId("com.chaozh.iReader:id/account_block_zhangyueid_login_submit"));
    loginbtn.click();
  }
 public boolean setText(final String text) throws UiObjectNotFoundException {
   return el.setText(text);
 }