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


Java UiObject.click方法代码示例

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


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

示例1: selectSettingsFor

import com.android.uiautomator.core.UiObject; //导入方法依赖的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.UiObject; //导入方法依赖的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: setSystemTime

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public void setSystemTime(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
    		.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date & time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set time")).click();

    AsusNexus72012sdk21TimePickerHelper.setTime(calendar);
    AsusNexus72012sdk21TimePickerHelper.clickOK();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:AsusNexus72012sdk21SystemDateTimeViewHelper.java

示例4: setSystemDate

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public void setSystemDate(Calendar calendar) throws UiObjectNotFoundException, IOException {
    ShellCommandUtils
            .executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date and time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set date")).click();

    AsusNexus72012sdk21DatePickerHelper.setDate(calendar);
    AsusNexus72012sdk21DatePickerHelper.clickOk();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:AsusNexus72012sdk21SystemDateTimeViewHelper.java

示例5: setYear

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
public static void setYear(int year) throws UiObjectNotFoundException {
    Calendar cal = Calendar.getInstance();
    int thisYear = cal.get(Calendar.YEAR);
    int incrementYearIndex = 1;
    int yearDifferential = Math.abs(thisYear - year);
    String yearText = String.format("%d", year);
    UiObject yearTextView = new UiObject(new UiSelector().resourceId("android:id/date_picker_year"));

    if (yearTextView.getText().equals(yearText)) {
        return;
    }

    if (year > thisYear) {
        incrementYearIndex = 3;
    }

    for (int i = 0; i < yearDifferential; i++) {
        yearTextView.click();
        new UiObject(new UiSelector().resourceId("android:id/month_text_view").index(incrementYearIndex))
                .click();
    }
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:23,代码来源:AsusNexus72012sdk21DatePickerHelper.java

示例6: setSystemTime

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public void setSystemTime(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
			.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date and time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set time")).click();

    SamsungGalaxyS5sdk19TimePickerHelper.setTime(calendar);
    SamsungGalaxyS5sdk19TimePickerHelper.clickSet();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:SamsungGalaxyS5sdk19SystemDateTimeViewHelper.java

示例7: setSystemDate

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public void setSystemDate(Calendar calendar) throws UiObjectNotFoundException, IOException {
	ShellCommandUtils
			.executeShellCommand("/system/bin/am start -a android.settings.DATE_SETTINGS");

    UiObject dateAndTimeToggle = new UiObject(new UiSelector().text("Automatic date and time"));
    UiObject setDate = new UiObject(new UiSelector().text("Set date"));

    if (!setDate.isEnabled()) {
        dateAndTimeToggle.click();
    }

    new UiObject(
            new UiSelector().text("Set date")).click();

    SamsungGalaxyS5sdk19DatePickerHelper.setDate(calendar);
    SamsungGalaxyS5sdk19DatePickerHelper.clickSet();
}
 
开发者ID:SeaDroids,项目名称:CIWorkshopProjects,代码行数:19,代码来源:SamsungGalaxyS5sdk19SystemDateTimeViewHelper.java

示例8: openDownloadList

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and clicks the downloads
 * item to load the downloads list
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
private void openDownloadList() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().description("Navigate up"));
		upButton.click();
	}

	UiObject downloadsItem = navDrawer.getChild(new UiSelector()
			.text("Downloads"));
	downloadsItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:DownloadListUiTest.java

示例9: openDownloadInfoScreen

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and clicks the downloads
 * item to load the download list and then clicks the first item
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
protected void openDownloadInfoScreen() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().description("Navigate up"));
		upButton.click();
	}

	UiObject downloadsItem = navDrawer.getChild(new UiSelector()
			.text("Downloads"));
	downloadsItem.click();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	firstItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:29,代码来源:DownloadInfoUiTest.java

示例10: openVideoInfoScreen

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and click the home item to
 * load the thumb grid and then clicks the first item
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
protected void openVideoInfoScreen() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().description("Navigate up"));
		upButton.click();
	}

	UiObject homeItem = navDrawer.getChild(new UiSelector().text("Home"));
	homeItem.click();

	UiCollection grid = new UiCollection(
			new UiSelector().className("android.widget.GridView"));
	UiObject firstItem = grid.getChild(new UiSelector().index(0));
	firstItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:28,代码来源:VideoInfoUiTest.java

示例11: openThumbGrid

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and click the home item to
 * load the thumb grid
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
private void openThumbGrid() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().descriptionContains("navigation drawer"));
		upButton.clickAndWaitForNewWindow(1000);
	}

	UiObject homeItem = navDrawer.getChild(new UiSelector().text("Home"));
	homeItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:ThumbGridUiTest.java

示例12: openSettingsList

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Launches the app, opens the navigation drawer and clicks the settings
 * item to load the settings list
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
private void openSettingsList() throws RemoteException,
		UiObjectNotFoundException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().description("Navigate up"));
		upButton.click();
	}

	UiObject settingsItem = navDrawer.getChild(new UiSelector()
			.text("Settings"));
	settingsItem.click();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:SettingsListUiTest.java

示例13: testDemo

import com.android.uiautomator.core.UiObject; //导入方法依赖的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

示例14: testDemo

import com.android.uiautomator.core.UiObject; //导入方法依赖的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

示例15: clickView

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * 按文字点击
 * 
 * @param text
 */
public void clickView(String text) {
	try {
		UiObject uiObject = new UiObject(new UiSelector().text(text));
		uiObject.click();
	} catch (UiObjectNotFoundException e) {
		sleep(1 * 1000);
	}
	sleep(1000);
}
 
开发者ID:Xiangxingqian,项目名称:WeiXinGroupSend,代码行数:15,代码来源:LaunchSettings.java


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