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


Java UiSelector类代码示例

本文整理汇总了Java中com.android.uiautomator.core.UiSelector的典型用法代码示例。如果您正苦于以下问题:Java UiSelector类的具体用法?Java UiSelector怎么用?Java UiSelector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testDemo

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

示例2: handle

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws UiObjectNotFoundException {
    UiElementPropertiesContainer propertiesContainer = (UiElementPropertiesContainer) args[0];
    SwipeDirection direction = (SwipeDirection) args[1];

    UiSelector selector = UiSelectorParser.convertSelector(propertiesContainer);

    UiObject element = new UiObject(selector);
    switch (direction) {
        case DOWN:
            element.swipeDown(SWIPE_STEPS_COUNT);
            break;
        case UP:
            element.swipeUp(SWIPE_STEPS_COUNT);
            break;
        case LEFT:
            element.swipeLeft(SWIPE_STEPS_COUNT);
            break;
        case RIGHT:
            element.swipeRight(SWIPE_STEPS_COUNT);
            break;
    }

    return UIAutomatorRequest.VOID_RESPONSE;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:26,代码来源:ElementSwiper.java

示例3: handle

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
@Override
public Object handle(Object[] args) throws UiObjectNotFoundException {
    UiElementPropertiesContainer propertiesContainer = (UiElementPropertiesContainer) args[0];

    UiSelector selector = UiSelectorParser.convertSelector(propertiesContainer);

    UiObject field = new UiObject(selector);

    field.clearTextField();

    for (int i = 0; i < ACTION_TIMEOUT_SECONDS / (ACTION_TIMEOUT_STEP / 1000); i++) {
        String text = field.getText();
        if (!text.isEmpty()) {
            try {
                Thread.sleep(ACTION_TIMEOUT_STEP);
            } catch (InterruptedException e) {
                // Nothing to do here
            }
        } else {
            break;
        }
    }

    return UIAutomatorRequest.VOID_RESPONSE;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:26,代码来源:TextFieldEraser.java

示例4: setUiSelectorClassNameWithSelectionOption

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
private static UiSelector setUiSelectorClassNameWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            String pattern = "^.*%s.*$";
            uiSelector = uiSelector.classNameMatches(String.format(pattern, propertyPair.getKey()));
            break;
        case EQUALS:
            uiSelector = uiSelector.className(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.classNameMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.className(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java

示例5: setUiSelectorPackageWithSelectionOption

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
private static UiSelector setUiSelectorPackageWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            String pattern = "^.*%s.*$";
            uiSelector = uiSelector.packageNameMatches(String.format(pattern, propertyPair.getKey()));
            break;
        case EQUALS:
            uiSelector = uiSelector.packageName(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.packageNameMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.packageName(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java

示例6: setUiSelectorTextWithSelectionOption

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
private static UiSelector setUiSelectorTextWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            uiSelector = uiSelector.textContains(propertyPair.getKey());
            break;
        case EQUALS:
            uiSelector = uiSelector.text(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.textMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.text(propertyPair.getKey());
            break;

    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:20,代码来源:UiSelectorParser.java

示例7: setUiSelectorDescriptionWithSelectionOption

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
private static UiSelector setUiSelectorDescriptionWithSelectionOption(UiSelector uiSelector, Pair<String, UiElementSelectionOption> propertyPair) {
    switch (propertyPair.getValue()) {
        case CONTAINS:
            uiSelector = uiSelector.descriptionContains(propertyPair.getKey());
            break;
        case EQUALS:
            uiSelector = uiSelector.description(propertyPair.getKey());
            break;
        case WORD_MATCH:
            uiSelector = uiSelector.descriptionMatches(propertyPair.getKey());
            break;
        default:
            uiSelector = uiSelector.description(propertyPair.getKey());
            break;
    }

    return uiSelector;
}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:19,代码来源:UiSelectorParser.java

示例8: setSystemTime

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

示例9: setSystemDate

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

示例10: setYear

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

示例11: openThumbGrid

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

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

示例13: setSystemDate

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

示例14: testGridSearchClick

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
/**
 * Tests whether the grid view shows a search box when the search option is
 * clicked
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testGridSearchClick() throws RemoteException,
		UiObjectNotFoundException {
	openThumbGrid();

	UiObject search = new UiObject(new UiSelector().description("Search"));

	assertTrue("Search view isn't clicked", search.click());

	UiObject searchView = new UiObject(
			new UiSelector().description("Search query"));
	assertTrue("SearchView doesn't exist", searchView.exists());
	assertTrue("SearchView isn't enabled", searchView.isEnabled());
	assertTrue("SearchView isn't clickable", searchView.isClickable());
	assertEquals("SearchView text isn't correct", "Search videos",
			searchView.getText().trim());
	assertEquals("SearchView isn't an EditText", "android.widget.EditText",
			searchView.getClassName());

	// press back twice to return to home
	getUiDevice().pressBack();
	getUiDevice().pressBack();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:30,代码来源:ThumbGridUiTest.java

示例15: testListItemTitle

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
/**
 * Tests whether the first item contains an existing and enabled title
 * TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testListItemTitle() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadList();

	UiCollection list = new UiCollection(
			new UiSelector().className("android.widget.ListView"));
	UiObject firstItem = list.getChild(new UiSelector().index(0));
	UiObject title = firstItem.getChild(new UiSelector().index(0));

	assertTrue("Title doesn't exist", title.exists());
	assertTrue("Title isn't enabled", title.isEnabled());
	assertEquals("Title isn't a TextView", "android.widget.TextView",
			title.getClassName());
	assertFalse("Title is empty string", title.getText().equals(""));
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:DownloadListUiTest.java


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