• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UiSelector类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testListItemStatus

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

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

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


示例17: testListItemDownloadSpeed

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

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

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


示例18: testListItemUploadSpeed

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

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

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


示例19: openDownloadList

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


示例20: testDownloadInfoSizeTitle

import com.android.uiautomator.core.UiSelector; //导入依赖的package包/类
/**
 * Tests whether the download info screen contains the size TextView
 * 
 * @throws RemoteException
 * @throws UiObjectNotFoundException
 */
public void testDownloadInfoSizeTitle() throws RemoteException,
		UiObjectNotFoundException {
	openDownloadInfoScreen();

	UiObject infoView = new UiObject(
			new UiSelector().className("android.widget.RelativeLayout"));
	UiObject parent = infoView.getChild(new UiSelector().index(0));
	UiObject filesizeTitle = parent.getChild(new UiSelector().index(0));

	assertTrue("Filesize title view doesn't exist", filesizeTitle.exists());
	assertTrue("Filesize title view isn't enabled",
			filesizeTitle.isEnabled());
	assertEquals("Filesize title view isn't a TextView",
			"android.widget.TextView", filesizeTitle.getClassName());
	assertEquals("Filesize title is incorrect string", "Size:",
			filesizeTitle.getText());
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:24,代码来源:DownloadInfoUiTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Scene类代码示例发布时间:2022-05-21
下一篇:
Java NegTokenTarg类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap