當前位置: 首頁>>代碼示例>>Java>>正文


Java UiObject.getText方法代碼示例

本文整理匯總了Java中android.support.test.uiautomator.UiObject.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java UiObject.getText方法的具體用法?Java UiObject.getText怎麽用?Java UiObject.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.test.uiautomator.UiObject的用法示例。


在下文中一共展示了UiObject.getText方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: test027CheckSearchHistory

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Category(CategoryAppStoreTests_v3_3_15.class)
@Test
public void test027CheckSearchHistory() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotOne = device.findObject(By.res("woyou.market:id/linear_hot_view")).findObject(By.res("woyou.market:id/tv_name"));
    String targetAppName = hotOne.getText();
    UiObject2 searchObj = device.findObject(By.res("woyou.market:id/tv_search").text("搜索"));
    searchObj.click();
    TestUtils.screenshotCap("afterClickSearchBtn");
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 searchObj1 = device.findObject(By.res("woyou.market:id/et_search").text("搜索").focused(true));
    searchObj1.click();
    searchObj1.setText(targetAppName);
    TestUtils.screenshotCap("enterSearchContent");
    UiScrollable appList = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject appInfo = appList.getChildByInstance(new UiSelector().className("android.widget.FrameLayout"),0);
    UiObject appNameObj = appInfo.getChild(new UiSelector().resourceId("woyou.market:id/tv_name"));
    String appName = appNameObj.getText();
    appInfo.click();
    TestUtils.screenshotCap("enterTheFirstSearchResult");
    device.pressBack();
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 clearButton = device.findObject(By.res("woyou.market:id/iv_delete"));
    clearButton.click();
    TestUtils.screenshotCap("clearSearchBar");
    TestUtils.sleep(SHORT_SLEEP);
    String historyObjName = device.findObject(By.res("woyou.market:id/history_key")).findObject(By.clazz("android.widget.TextView")).getText();
    Assert.assertEquals("期望的名字是"+appName+",而實際是"+historyObjName,appName,historyObjName);
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:30,代碼來源:SunmiAppStore_v3_3_15.java

示例2: test027CheckSearchHistory

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
@Test
public void test027CheckSearchHistory() throws UiObjectNotFoundException {
    TestUtils.screenshotCap("appStoreHome");
    UiObject2 hotOne = device.findObject(By.res("woyou.market:id/linear_hot_view")).findObject(By.res("woyou.market:id/tv_name"));
    String targetAppName = hotOne.getText();
    UiObject2 searchObj = device.findObject(By.res("woyou.market:id/tv_search").text("搜索"));
    searchObj.click();
    TestUtils.screenshotCap("afterClickSearchBtn");
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 searchObj1 = device.findObject(By.res("woyou.market:id/et_search").text("搜索").focused(true));
    searchObj1.click();
    searchObj1.setText(targetAppName);
    TestUtils.screenshotCap("enterSearchContent");
    UiScrollable appList = new UiScrollable(new UiSelector().resourceId("woyou.market:id/list_view"));
    UiObject appInfo = appList.getChildByInstance(new UiSelector().resourceId("woyou.market:id/app_view"),0);
    UiObject appNameObj = appInfo.getChild(new UiSelector().resourceId("woyou.market:id/tv_name"));
    String appName = appNameObj.getText();
    appInfo.click();
    TestUtils.screenshotCap("enterTheFirstSearchResult");
    device.pressBack();
    TestUtils.sleep(SHORT_SLEEP);
    UiObject2 clearButton = device.findObject(By.res("woyou.market:id/iv_delete"));
    clearButton.click();
    TestUtils.screenshotCap("clearSearchBar");
    TestUtils.sleep(SHORT_SLEEP);
    String historyObjName = device.findObject(By.res("woyou.market:id/history_key")).findObject(By.clazz("android.widget.TextView")).getText();
    Assert.assertEquals("期望的名字是"+appName+",而實際是"+historyObjName,appName,historyObjName);
}
 
開發者ID:sunmiqa,項目名稱:SunmiAuto,代碼行數:29,代碼來源:SunmiAppStore.java

示例3: getUiObjectDisplay

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
public String getUiObjectDisplay(UiObject object) {
    String display = "";
    try {
        display = object.getText();
        if (display == null || display.length() == 0) {
            display = object.getContentDescription();
        }
    } catch (UiObjectNotFoundException e) {
        Log.e("Chimp-wildCardManager","UiObject not found while getting display strings",e);
    }
    return display;
}
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:13,代碼來源:WildCardManager.java

示例4: uiObjectInfo

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
public String uiObjectInfo(UiObject object) throws UiObjectNotFoundException {
    return object.hashCode() + " " + object.toString() + " " + object.getClassName() +
            object.getText() + " " + object.getContentDescription() + " " + object.getChildCount();
}
 
開發者ID:cuplv,項目名稱:ChimpCheck,代碼行數:5,代碼來源:WildCardManager.java

示例5: testFieldWithName

import android.support.test.uiautomator.UiObject; //導入方法依賴的package包/類
/**
 * @param index - The idnex of the field in the list (start at 0)
 * @param text - The text of the field to get
 */
private void testFieldWithName( int index, String text ){

    if ( text == null || text.length() <= 0 || index < 0){
        fail("Wrong test");
    }

    final String DUMMY_TEXT = "Hello world";

    try {
        // Display the dialog
        UiObject field = mDevice.findObject(
                new UiSelector()
                        .className("android.widget.TextView")
                        .packageName(PACKAGE_APP_PATH)
                        .resourceId("android:id/title")
                        .text(text)
        );
        field.click();
        // Change the value
        field = mDevice.findObject(
                new UiSelector()
                        .className("android.widget.EditText")
                        .packageName(PACKAGE_APP_PATH)
                        .resourceId("android:id/edit")
        );
        final String BACKUP_TEXT = field.getText();
        field.setText(DUMMY_TEXT);
        // Confirm
        UiObject button = mDevice.findObject(
                new UiSelector()
                        .className("android.widget.Button")
                        .packageName(PACKAGE_APP_PATH)
                        .resourceId("android:id/button1")
        );
        button.click();
        w(1000);
        // Check the summary
        BySelector checkboxSettingsSelector = By.clazz("android.widget.TextView");
        List<UiObject2> summaries = mDevice.findObjects(checkboxSettingsSelector);
        UiObject2 field2 = summaries.get( index * 4 + 2 );
        assertEquals(DUMMY_TEXT, field2.getText());
        // Reset the value
        resetFieldWithText( DUMMY_TEXT, BACKUP_TEXT );
    } catch ( UiObjectNotFoundException uonfe ){
        uonfe.printStackTrace();
        fail(uonfe.getMessage());
    }

}
 
開發者ID:pylapp,項目名稱:SmoothClicker,代碼行數:54,代碼來源:ItSettingsActivity.java


注:本文中的android.support.test.uiautomator.UiObject.getText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。