当前位置: 首页>>代码示例>>Java>>正文


Java UiScrollable.getChildByText方法代码示例

本文整理汇总了Java中com.android.uiautomator.core.UiScrollable.getChildByText方法的典型用法代码示例。如果您正苦于以下问题:Java UiScrollable.getChildByText方法的具体用法?Java UiScrollable.getChildByText怎么用?Java UiScrollable.getChildByText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.uiautomator.core.UiScrollable的用法示例。


在下文中一共展示了UiScrollable.getChildByText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: selectSettingsFor

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * Select a settings items and perform scroll if needed to find it.
 * @param name
 */
private boolean selectSettingsFor(String name)  {
    try {
        UiScrollable appsSettingsList = new UiScrollable(SettingsHelper.LIST_VIEW);
        UiObject obj = appsSettingsList.getChildByText(SettingsHelper.LIST_VIEW_ITEM, name);
        obj.click();
    } catch (UiObjectNotFoundException e) {
        return false;
    }
    return true;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:15,代码来源:LogBuildNumber.java

示例2: testDemo

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
public void testDemo() throws UiObjectNotFoundException {

        // Press on the HOME button.
        getUiDevice().pressHome();

        // Launch the "Google" apps via the All Apps screen.
        UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
        allAppsButton.clickAndWaitForNewWindow();
        UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
        appsTab.click();
        UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
        appViews.setAsHorizontalList();
        UiObject testApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
                "Google");
        testApp.clickAndWaitForNewWindow();

        // Get the google search text box
        UiObject searchBox = new UiObject(
                new UiSelector().className("com.google.android.search.shared.ui.SimpleSearchText"));

        // do Japanese Input!
        searchBox.setText(Utf7ImeHelper.e("こんにちは!UiAutomatorで入力しています。"));
    }
 
开发者ID:Xiangxingqian,项目名称:WeiXinGroupSend,代码行数:24,代码来源:UiAutomatorInputTest.java

示例3: testLaunch

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * Play Store launch test.
 *
 * @throws UiObjectNotFoundException
 */
public void testLaunch() throws UiObjectNotFoundException {

    getUiDevice().pressHome();
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
    allAppsButton.clickAndWaitForNewWindow();

    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
    appsTab.click();

    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    appViews.setAsHorizontalList();

    UiObject settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),
            "Play Store");
    settingsApp.clickAndWaitForNewWindow();

    UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.vending"));
    assertTrue("Unable to detect Play Store", settingsValidation.exists());
}
 
开发者ID:croute,项目名称:UiAutomatorExample,代码行数:25,代码来源:LaunchSettings.java

示例4: findAndRunApp

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
private void findAndRunApp() throws UiObjectNotFoundException {
    // Go to main screen
    getUiDevice().pressHome();
    // Find menu button
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
    // Click on menu button and wait new window
    allAppsButton.clickAndWaitForNewWindow();
    // Find App tab
    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
    // Click on app tab
    appsTab.click();
    // Find scroll object (menu scroll)
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    // Set the swiping mode to horizontal (the default is vertical)
    appViews.setAsHorizontalList();
    // Find Messaging application
    UiObject settingsApp = appViews.getChildByText(new UiSelector().className("android.widget.TextView"), "My Files");
    // Open Messaging application
    settingsApp.clickAndWaitForNewWindow();

    // Validate that the package name is the expected one
    UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.sec.android.app.myfiles"));
    assertTrue("Unable to detect MyFiles", settingsValidation.exists());
}
 
开发者ID:amazpyel,项目名称:uiautomator_sample,代码行数:25,代码来源:CopyFile.java

示例5: testDemo

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * Script starts here
 * @throws UiObjectNotFoundException
 */
public void testDemo() throws UiObjectNotFoundException {
    // The following code is documented in the LaunchSettings demo. For detailed description
    // of how this code works, look at the demo LaunchSettings

    // Good to start from here
    getUiDevice().pressHome();

    // open the All Apps view
    UiObject allAppsButton = new UiObject(LauncherHelper.ALL_APPS_BUTTON);
    allAppsButton.click();

    // clicking the APPS tab
    UiSelector appsTabSelector =
            new UiSelector().className(android.widget.TabWidget.class.getName())
                .childSelector(new UiSelector().text("Apps"));
    UiObject appsTab = new UiObject(appsTabSelector);
    appsTab.click();

    // Clicking the Settings
    UiScrollable allAppsScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    allAppsScreen.setAsHorizontalList();
    UiObject settingsApp =
            allAppsScreen.getChildByText(LauncherHelper.LAUNCHER_ITEM, "Settings");
    settingsApp.click();

    // Now we will select the settings we need to work with. To make this operation a little
    // more generic we will put it in a function. We will try it as a phone first then as a
    // tablet if phone is not our device type
    if (!selectSettingsFor("About phone"))
        selectSettingsFor("About tablet");

    // Now we need to read the Build number text and return it
    String buildNum = getAboutItem("Build number");

    // Log it - Use adb logcat to view the results
    Log.i(LOG_TAG, "Build = " + buildNum);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:42,代码来源:LogBuildNumber.java

示例6: testDemo

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * Set an alarm 2 minutes from now and verify it goes off. Also check the notification
 * shades for an alarm. (Crude test but it demos the use of Android resources)
 * @throws UiObjectNotFoundException
 */
public void testDemo() throws UiObjectNotFoundException {
    // The following code is documented in the LaunchSettings demo. For detailed description
    // of how this code works, look at the demo LaunchSettings

    // Good to start from here
    getUiDevice().pressHome();

    // open the All Apps view
    UiObject allAppsButton = new UiObject(LauncherHelper.ALL_APPS_BUTTON);
    allAppsButton.click();

    // clicking the APPS tab
    UiSelector appsTabSelector =
            new UiSelector().className(android.widget.TabWidget.class.getName())
                .childSelector(new UiSelector().text("Apps"));
    UiObject appsTab = new UiObject(appsTabSelector);
    appsTab.click();

    // Clicking the Settings
    UiScrollable allAppsScreen = new UiScrollable(LauncherHelper.LAUNCHER_CONTAINER);
    allAppsScreen.setAsHorizontalList();
    UiObject clockApp =
            allAppsScreen.getChildByText(LauncherHelper.LAUNCHER_ITEM, "Clock");
    clockApp.click();

    // Set an alarm to go off in about 2 minutes
    setAlarm(2);

    // wait for the alarm alert dialog
    UiObject alarmAlert =
            new UiObject(new UiSelector().packageName("com.google.android.deskclock")
                    .className(TextView.class.getName()).text("Alarm"));

    assertTrue("Timeout while waiting for alarm to go off",
            alarmAlert.waitForExists(2 * 60 * 1000));

    clickByText("Dismiss");
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:44,代码来源:SetTwoMinuteAlarm.java

示例7: start_target_app

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
private void start_target_app(String appName) throws UiObjectNotFoundException {
		// 0. Start fromIndex HOME
		dev.pressHome();

		// 1. Find and click "Apps" button
		//NO Need to use that
//		UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
//
//		allAppsButton.clickAndWaitForNewWindow();

		// 2. Find and click “Apps” tab
		UiObject appsTab = new UiObject(new UiSelector().description("Apps"));
		if (launcherPackName == null) {
			launcherPackName = appsTab.getPackageName(); // remember the launcher package
		}
		appsTab.click();

		// 3. Select scrollable "container view" 
		UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
		// Set the swiping mode to horizontal (the default is vertical)
		appViews.setAsHorizontalList();

		// 4. This API does not work properly in 4.2.2 
		appViews.scrollTextIntoView(appName);

		// 5. Click target app
		UiObject targetApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName, true);

		boolean done = targetApp.clickAndWaitForNewWindow();

		waitForNetworkUpdate();
		// AccessibilityEventProcessor.waitForLastEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED, WINDOW_CONTENT_UPDATE_TIMEOUT);
	}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:34,代码来源:EnhancedPUMALauncher.java

示例8: clickOnText

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
public void clickOnText(String text, boolean scroll, int maxScrol)
		throws UiObjectNotFoundException {
	if (!scroll) {
		clickOnText(text);
	} else {
		UiScrollable selScroll = new UiScrollable(new UiSelector());
		
		try {
			selScroll.setMaxSearchSwipes(maxScrol);
		} catch (Exception e) {
			//Do nothing
		}
		
		selScroll.scrollTextIntoView(text);
		selScroll.waitForExists(DEFAULT_DELAY);

		// Create the object
		UiObject objScrollable = selScroll
				.getChildByText(new UiSelector()
						.className(Constants.TEXT_VIEW_CLASS), text);
		if (objScrollable.exists()) {
			// Click on object into the listView
			objScrollable.click();
		} else {
			throw new UiObjectNotFoundException(
					"There is no object on list or the list do not exists on window");
		}
	}
}
 
开发者ID:thiagoolsilva,项目名称:UiAutomatorFramework,代码行数:30,代码来源:Clicker.java

示例9: getCustomerItem

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * 顧客名一覧のListViewの中から、指定された顧客名が表示されているリストアイテムを取得する(スクロール対応版)。
 * 
 * @param customerName 検索したい顧客名
 */
@Override
protected UiObject getCustomerItem(String customerName) throws UiObjectNotFoundException {
    UiScrollable customerList = new UiScrollable(new UiSelector().className(ListView.class.getName()));
    // スクロール方向を指定する
    customerList.setAsVerticalList();
    return customerList.getChildByText(new UiSelector().className(TextView.class.getName()), customerName);
}
 
开发者ID:nowsprinting,项目名称:AndroidAppsTestAutomationSamples,代码行数:13,代码来源:MasterPageScrollSupport.java

示例10: startApp

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * 無効化マネージャーを起動する
 */
private void startApp() throws Exception {
    getUiDevice().pressHome();
    getUiDevice().pressBack();

    Runtime.getRuntime().exec("am start -n com.nagopy.android.disablemanager2/.MainActivity");
    if (true) return;

    UiObject allAppsButton = new UiObject(
            new UiSelectorBuilder()
                    .description("アプリ").build()
    );
    allAppsButton.clickAndWaitForNewWindow();

    UiScrollable appViews = new UiScrollable(
            new UiSelectorBuilder().
                    scrollable(true).build()
    );
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        appViews.setAsHorizontalList();
    }
    UiObject settingsApp = appViews.getChildByText(
            new UiSelectorBuilder()
                    .className(TextView.class.getName()).build(),
            "無効化マネージャー");
    settingsApp.clickAndWaitForNewWindow();

    assertTrue("アプリ起動に失敗", TestUtils.isTargetApp(TestUtils.PACKAGE_NAME));
}
 
开发者ID:75py,项目名称:DisableManager,代码行数:32,代码来源:MainActivityTestCase.java

示例11: testSetInternetAsDefault

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
public void testSetInternetAsDefault() throws UiObjectNotFoundException {
	if(Build.VERSION.SDK_INT >= 18){
		Configurator config = Configurator.getInstance();
		config.setWaitForSelectorTimeout(2000); // Set UI wait timeout for 2 seconds
	}
	
	// Get installed app list
	UiScrollable deviceAdminList = 
			new UiScrollable(new UiSelector().className("android.widget.GridView"));
	
	// First device admin receiver
	UiObject internet = 
			deviceAdminList.getChildByText(
					new UiSelector().className("android.widget.LinearLayout"), 
					"Internet");
	
	// select internet
	internet.click();
	
	UiObject alwaysBtn = new UiObject(new UiSelector().text("Always"));
	alwaysBtn.click();
	
	UiObject okBtn = new UiObject(new UiSelector().text("OK"));
	okBtn.click();
	
	// Done!
	UiDevice.getInstance().pressHome();
	
}
 
开发者ID:kunny,项目名称:PreCTS,代码行数:30,代码来源:PreCTSAutomate.java

示例12: testDemo

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
public void testDemo() throws UiObjectNotFoundException {
    // Good practice to start from a common place
    getUiDevice().pressHome();

    // When we use the uiautomatorviewer in the DSK/tools we find that this
    // button has the following content-description
    UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));

    // ** NOTE **
    // Any operation on a UiObject that is not currently present on the display
    // will result in a UiObjectNotFoundException to be thrown. If we want to
    // first check if the object exists we can use allAppsButton.exists() which
    // return boolean.
    // ** NOTE **

    //The operation below expects the click will result a new  window.
    allAppsButton.clickAndWaitForNewWindow();

    // On the this view, we expect two tabs, one for APPS and another for
    // WIDGETS. We will want to click the APPS just so we're sure apps and
    // not widgets is our current display
    UiObject appsTab = new UiObject(new UiSelector().text("Apps"));

    // ** NOTE **
    // The above operation assumes that there is only one text "Apps" in the
    // current view. If not, then the first "Apps" is selected. But if we
    // want to be certain that we click on the tab "Apps", we can use the
    // uiautomatorview from the SDK/tools and see if we can further narrow the
    // selector. Comment the line above and uncomment the one bellow to use
    // the more specific selector.
    // ** NOTE **

    // This creates a selector hierarchy where the first selector is for the
    // TabWidget and the second will search only inside the layout of TabWidget
    // To use this instead, uncomment the lines bellow and comment the above appsTab
    //UiSelector appsTabSelector =
    //        new UiSelector().className(android.widget.TabWidget.class.getName())
    //            .childSelector(new UiSelector().text("Apps"));
    //UiObject appsTab = new UiObject(appsTabSelector);


    // The operation below we only cause a content change so a click() is good
    appsTab.click();

    // Since our device may have many apps on it spanning multiple views, we
    // may need to scroll to find our app. Here we use UiScrollable to help.
    // We declare the object with a selector to a scrollable view. Since in this
    // case the firt scrollable view happens to be the one containing our apps
    // list, we should be ok.
    UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
    // swipe horizontally when searching (default is vertical)
    appViews.setAsHorizontalList();

    // the appsViews will perform horizontal scrolls to find the Settings app
    UiObject settingsApp = appViews.getChildByText(
            new UiSelector().className(android.widget.TextView.class.getName()), "Settings");
    settingsApp.clickAndWaitForNewWindow();

    // create a selector for anything on the display and check if the package name
    // is the expected one
    UiObject settingsValidation =
            new UiObject(new UiSelector().packageName("com.android.settings"));

    assertTrue("Unable to detect Settings", settingsValidation.exists());
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:66,代码来源:LaunchSettings.java

示例13: testStartLocalServerUsingTestContent

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
/**
 * Select start local server with test content in the settings menu.
 * @throws Exception
 */
public void testStartLocalServerUsingTestContent()
		throws Exception {
	openYaacc();		
	getUiDevice().pressMenu(); // open option menu
	UiScrollable settingsMenu = new UiScrollable(
			new UiSelector().className("android.widget.ListView"));
	UiObject settingsItem = settingsMenu.getChild(new UiSelector().className("android.widget.TextView")
			.text("Settings"));
	settingsItem.clickAndWaitForNewWindow();

	UiObject validation = new UiObject(new UiSelector().text("Settings").className(
			android.widget.TextView.class));
	assertTrue("Unable to open Yaacc settings ", validation.exists());
	UiScrollable settingsList = new UiScrollable(new UiSelector().className("android.widget.ListView").scrollable(true));
	assertTrue("Unbale to find list view  for settings ", settingsList.exists());
	//Scroll to server settings
	settingsList.getChildByText(new UiSelector().className(android.widget.TextView.class), "Local server configuration");
	int itemCount = settingsList.getChildCount(new UiSelector().className(android.widget.LinearLayout.class));
	assertTrue("itemCount > 0 (" + itemCount + ")", itemCount > 0);
	for (int i = 0; i < itemCount; i++){
		UiObject item = settingsList.getChildByInstance(new UiSelector().className(android.widget.LinearLayout.class), i);
		UiObject textView = item.getChild(new UiSelector().textStartsWith("local server").className(
				android.widget.TextView.class));
		if(textView.exists()){
			UiObject checkBox = item.getChild(new UiSelector().className(
					android.widget.CheckBox.class));
			assertTrue("CheckBox not found", checkBox.exists());
			if(!checkBox.isChecked()){
				checkBox.click();
			}
		}
		
	}
	
	
	
	//Back to BrowseActivity
	getUiDevice().pressBack();
	closeBrowseActivity();

}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:46,代码来源:UITestCase.java

示例14: openYaacc

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
private void openYaacc() throws Exception {
	// Simulate a short press on the HOME button.
	getUiDevice().pressHome();

	// Were now in the home screen. Next, we want to simulate
	// a user bringing up the All Apps screen.
	// If you use the uiautomatorviewer tool to capture a snapshot
	// of the Home screen, notice that the All Apps buttons
	// content-description property has the value Apps. We can
	// use this property to create a UiSelector to find the button.
	UiObject allAppsButton = new UiObject(
			new UiSelector().description("Apps"));

	// Simulate a click to bring up the All Apps screen.
	allAppsButton.clickAndWaitForNewWindow();

	// In the All Apps screen, the Settings app is located in
	// the Apps tab. To simulate the user bringing up the Apps tab,
	// we create a UiSelector to find a tab with the text
	// label Apps.
	UiObject appsTab = new UiObject(new UiSelector().text("Apps"));

	// Simulate a click to enter the Apps tab.
	appsTab.click();

	// Next, in the apps tabs, we can simulate a user swiping until
	// they come to the Settings app icon. Since the container view
	// is scrollable, we can use a UiScrollable object.
	UiScrollable appViews = new UiScrollable(
			new UiSelector().scrollable(true));

	// Set the swiping mode to horizontal (the default is vertical)
	appViews.setAsHorizontalList();

	// Create a UiSelector to find the Yaacc app and simulate
	// a user click to launch the app.
	UiObject yaaccApp = appViews.getChildByText(new UiSelector()
			.className(android.widget.TextView.class.getName()), "YAACC");
	yaaccApp.clickAndWaitForNewWindow();
	
}
 
开发者ID:theopenbit,项目名称:yaacc-code,代码行数:42,代码来源:UITestCase.java

示例15: start_target_app

import com.android.uiautomator.core.UiScrollable; //导入方法依赖的package包/类
private void start_target_app() throws UiObjectNotFoundException {
	// 0. Start fromIndex HOME
	dev.pressHome();

	// 1. Find and click "Apps" button
	// TODO: this is ad hoc fix for CM-10.2 nightly snapshot only
	UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));

	//		int cnt = 0;
	//		boolean end = false;
	//		while (!end) {
	//			UiObject obj = new UiObject(new UiSelector().packageName("com.cyanogenmod.trebuchet").className("android.widget.TextView").instance(cnt));
	//			cnt++;
	//
	//			try {
	//				obj.getBounds();
	//			} catch (UiObjectNotFoundException exception) {
	//				end = true;
	//			}
	//		}
	//		Util.log("HOME: " + (cnt - 1) + " TextViews");
	//
	//		if ((cnt - 1) < 5) {
	//			Util.err("ERR: NOT_AT_HOME");
	//			System.exit(-1);
	//		}
	//
	//		// Now there are (cnt-1) TextViews, "Apps" should be the (cnt-4)-th.
	//		UiObject allAppsButton = new UiObject(new UiSelector().packageName("com.cyanogenmod.trebuchet").className("android.widget.TextView").instance(cnt - 4));
	allAppsButton.clickAndWaitForNewWindow();

	// 2. Find and click “Apps” tab
	if (android.os.Build.VERSION.SDK_INT < 21) {
		//Add by Ruiyi He to avoid "Apps" cause in 5.0 this feature didnt exist
		UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
		launcherPackName = appsTab.getPackageName(); // remember the launcher package
		appsTab.click();
	}
	

	// 3. Select scrollable "container view" 
	UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
	// Set the swiping mode to horizontal (the default is vertical)
	appViews.setAsHorizontalList();

	// 4. This API does not work properly in 4.2.2 
	appViews.scrollTextIntoView(appName);

	// 5. Click target app
	UiObject targetApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName, true);

	boolean done = targetApp.clickAndWaitForNewWindow();
	// Util.log("clickAndWaitForNewWindow: " + done);

	waitForNetworkUpdate();
	// AccessibilityEventProcessor.waitForLastEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED, WINDOW_CONTENT_UPDATE_TIMEOUT);
}
 
开发者ID:MagicHry,项目名称:EnhancedPUMA,代码行数:58,代码来源:LaunchApp.java


注:本文中的com.android.uiautomator.core.UiScrollable.getChildByText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。