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


Java BySelector类代码示例

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


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

示例1: retrieveUiObject2s

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public ArrayList<UiObject2> retrieveUiObject2s(BySelector topLevelSelector, BySelector childSelector, int depth) throws UiObjectNotFoundException {
    if (depth == 0) { return new ArrayList<>(); }
    ArrayList<UiObject2> currUiObjects = retrieveTopLevelUiObjects(topLevelSelector);
    ArrayList<UiObject2> baseUiObjects = new ArrayList<>();
    while (depth > 0 && currUiObjects.size() > 0) {
        ArrayList<UiObject2> tempUiObjects = new ArrayList<>();
        for(UiObject2 currUiObject: currUiObjects) {
            if (currUiObject.getChildCount() != 0) {
                tempUiObjects.addAll( retrieveChildUiObjects(currUiObject, childSelector) );
            } else {
                baseUiObjects.add( currUiObject );
            }
        }
        currUiObjects = tempUiObjects;
        depth--;
    }

    String str = "/***** Inferred Actionable UI Objects *****/\n";
    for(UiObject2 candidate: new HashSet<UiObject2>(baseUiObjects)) {
        str += "Found candidate: " + candidate.getClassName() + " " + candidate.getText() + " " + candidate.getContentDescription() + "\n";
    }
    str += "/******************************************/";
    Log.i("Chimp-wildCardManager",str);

    return baseUiObjects;
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:27,代码来源:WildCardManager.java

示例2: getSelector

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
private static BySelector getSelector(String strategy, String text) throws Exception {
    BySelector selector = null;
    switch (strategy) {
        case "CLASS_NAME":
            selector = By.clazz(text);
            break;
        case "NAME":
            selector = By.desc(text);
            if(selector == null || elements.getmDevice().findObject(selector) == null){
                selector = By.text(text);
            }
            break;
        case "ID":
            selector = By.res(text);
            break;
    }
    return selector;
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:19,代码来源:ElementController.java

示例3: prepareParentalControl

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
/**
 * Prepare the need for testRatingDependentSelect.
 * 1. Turn on parental control if it's off.
 * 2. Make sure Japan rating system is selected.
 */
private void prepareParentalControl() {
    showParentalControl();
    switchParentalControl(R.string.option_toggle_parental_controls_off);
    // Show all rating systems.
    mSidePanelHelper.assertNavigateToItem(R.string.option_program_restrictions);
    mDevice.pressDPadCenter();
    BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
            R.string.option_program_restrictions);
    assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
    mSidePanelHelper.assertNavigateToItem(R.string.option_country_rating_systems);
    mDevice.pressDPadCenter();
    bySidePanel = mSidePanelHelper.bySidePanelTitled(R.string.option_country_rating_systems);
    assertWaitForCondition(mDevice,Until.hasObject(bySidePanel));
    mSidePanelHelper.assertNavigateToItem(R.string.option_see_all_rating_systems);
    mDevice.pressDPadCenter();
    // Make sure Japan rating system is selected.
    UiObject2 ratingSystemCheckBox = mSidePanelHelper.assertNavigateToItem("Japan")
            .findObject(ByResource.id(mTargetResources, R.id.check_box));
    if (!ratingSystemCheckBox.isChecked()) {
        mDevice.pressDPadCenter();
        getInstrumentation().waitForIdleSync();
    }
    mDevice.pressBack();
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:30,代码来源:ParentalControlsTest.java

示例4: showParentalControl

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
private void showParentalControl() {
    // Show menu and select parental controls.
    mMenuHelper.showMenu();
    mMenuHelper.assertPressOptionsSettings();
    assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
    mSidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
    mDevice.pressDPadCenter();
    // Enter pin code.
    DialogHelper dialogHelper = new DialogHelper(mDevice, mTargetResources);
    dialogHelper.assertWaitForPinDialogOpen();
    dialogHelper.enterPinCodes();
    dialogHelper.assertWaitForPinDialogClose();
    BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
            R.string.menu_parental_controls);
    assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:17,代码来源:ParentalControlsTest.java

示例5: testKeepPausedWhileParentalControlChange

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public void testKeepPausedWhileParentalControlChange() {
    // Pause the playback.
    mDevice.pressKeyCode(KeyEvent.KEYCODE_MEDIA_PAUSE);
    mMenuHelper.assertWaitForMenu();
    assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE);
    // Show parental controls fragment.
    mMenuHelper.assertPressOptionsSettings();
    assertWaitForCondition(mDevice, Until.hasObject(mBySettingsSidePanel));
    mSidePanelHelper.assertNavigateToItem(R.string.settings_parental_controls);
    mDevice.pressDPadCenter();
    DialogHelper dialogHelper = new DialogHelper(mDevice, mTargetResources);
    dialogHelper.assertWaitForPinDialogOpen();
    dialogHelper.enterPinCodes();
    dialogHelper.assertWaitForPinDialogClose();
    BySelector bySidePanel = mSidePanelHelper.bySidePanelTitled(
            R.string.menu_parental_controls);
    assertWaitForCondition(mDevice, Until.hasObject(bySidePanel));
    mDevice.pressEnter();
    mDevice.pressEnter();
    mDevice.pressBack();
    mDevice.pressBack();
    // Return to the main menu.
    mMenuHelper.assertWaitForMenu();
    assertButtonHasFocus(BUTTON_INDEX_PLAY_PAUSE);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:26,代码来源:PlayControlsRowViewTest.java

示例6: assertAppStarted

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public void assertAppStarted() {
    Intent intent = mContext.getPackageManager()
            .getLaunchIntentForPackage(Constants.TV_APP_PACKAGE);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);    // Clear out any previous instances
    mContext.startActivity(intent);
    // Wait for idle state before checking the channel banner because waitForCondition() has
    // timeout.
    mUiDevice.waitForIdle();
    // Make sure that the activity is resumed.
    waitForCondition(mUiDevice, Until.hasObject(Constants.TV_VIEW));

    Assert.assertTrue(Constants.TV_APP_PACKAGE + " did not start", mUiDevice
            .wait(Until.hasObject(By.pkg(Constants.TV_APP_PACKAGE).depth(0)),
                    APPLICATION_START_TIMEOUT_MSEC));
    BySelector welcome = ByResource.id(mTargetResources, com.android.tv.R.id.intro);
    if (mUiDevice.hasObject(welcome)) {
        Log.i(TAG, "Welcome screen shown. Clearing dialog by pressing back");
        mUiDevice.pressBack();
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:21,代码来源:LiveChannelsUiDeviceHelper.java

示例7: getChild

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public Object getChild(final Object selector) throws UiObjectNotFoundException, InvalidSelectorException, ClassNotFoundException {
    if (selector instanceof UiSelector) {
        /**
         * We can't find the child element with UiSelector on UiObject2,
         * as an alternative creating UiObject with UiObject2's AccessibilityNodeInfo
         * and finding the child element on UiObject.
         */
        AccessibilityNodeInfo nodeInfo = AccessibilityNodeInfoGetter.fromUiObject(element);

        UiSelector uiSelector = new UiSelector();
        CustomUiSelector customUiSelector = new CustomUiSelector(uiSelector);
        uiSelector = customUiSelector.getUiSelector(nodeInfo);
        UiObject uiObject = (UiObject)  CustomUiDevice.getInstance().findObject(uiSelector);
        AccessibilityNodeInfo uiObject_nodeInfo = AccessibilityNodeInfoGetter.fromUiObject(element);
        return uiObject.getChild((UiSelector) selector);
    }
    return element.findObject((BySelector) selector);
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:19,代码来源:UiObject2Element.java

示例8: getChildren

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public List<Object> getChildren(final Object selector, final By by) throws UiObjectNotFoundException, InvalidSelectorException, ClassNotFoundException {
    if (selector instanceof UiSelector) {
        /**
         * We can't find the child elements with UiSelector on UiObject2,
         * as an alternative creating UiObject with UiObject2's AccessibilityNodeInfo
         * and finding the child elements on UiObject.
         */
        AccessibilityNodeInfo nodeInfo = AccessibilityNodeInfoGetter.fromUiObject(element);

        UiSelector uiSelector = new UiSelector();
        CustomUiSelector customUiSelector = new CustomUiSelector(uiSelector);
        uiSelector = customUiSelector.getUiSelector(nodeInfo);
        UiObject uiObject = (UiObject)  CustomUiDevice.getInstance().findObject(uiSelector);
        String id = UUID.randomUUID().toString();
        AndroidElement androidElement = getAndroidElement(id, uiObject, by);
        return androidElement.getChildren(selector, by);
    }
    return (List)element.findObjects((BySelector) selector);
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:20,代码来源:UiObject2Element.java

示例9: Performer

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public Performer(String displayAction, ChimpDriver chimpDriver, ViewManager viewManager,
                 WildCardManager wildCardManager, BySelector wildCardSelector, BySelector wildCardChildSelector,
                 Matcher<View> userDefinedMatcher){
    this.displayAction = displayAction;
    this.chimpDriver = chimpDriver;
    this.viewManager = viewManager;
    this.wildCardManager = wildCardManager;
    this.wildCardSelector = wildCardSelector;
    this.wildCardChildSelector = wildCardChildSelector;
    this.userDefinedMatcher = userDefinedMatcher;
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:12,代码来源:Performer.java

示例10: scrollAndFind

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
/**
 * Scrolls the {@param container} until it finds an object matching {@param condition}.
 * @return the matching object.
 */
protected UiObject2 scrollAndFind(UiObject2 container, BySelector condition) {
    do {
        UiObject2 widget = container.findObject(condition);
        if (widget != null) {
            return widget;
        }
    } while (container.scroll(Direction.DOWN, 1f));
    return container.findObject(condition);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:14,代码来源:LauncherInstrumentationTestCase.java

示例11: getMultiElements

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
private static JSONArray getMultiElements(final BySelector sel) throws Exception {
    JSONArray res;
    List<Element> foundElements = new ArrayList<Element>();
    final List<Element> elementsFromSelector = getElements().getMultiElement(sel);
    foundElements.addAll(elementsFromSelector);
    res = elementsToJSONArray(foundElements);
    return res;
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:9,代码来源:ElementController.java

示例12: getElement

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public Element getElement(BySelector sel) throws Exception {
	UiObject2 el = mDevice.findObject(sel);
	Element result = addElement(el);
	if (el != null) {
		return result;
	} else {
		throw new Exception("not found");
	}
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:10,代码来源:Elements.java

示例13: getMultiElement

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public List<Element> getMultiElement(BySelector sel) throws Exception {
	List<UiObject2> el = mDevice.findObjects(sel);
	List<Element> result = addElements(el);
	if (result != null) {
		return result;
	} else {
		throw new Exception("not found");
	}
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:10,代码来源:Elements.java

示例14: testLaunchDialog

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
@Test
public void testLaunchDialog() {
    // Floating action button
    BySelector fabSelector = By.res(APP_PACKAGE, "invite_button");

    // Click floating action button
    Assert.assertTrue(mDevice.wait(Until.hasObject(fabSelector), UI_TIMEOUT));
    mDevice.findObject(fabSelector).click();

    // Radio button in the account picker dialog
    BySelector firstAccountSelector = By.clazz(CLASS_CHECKED_TEXT_VIEW);

    // Wait for account picker (may not appear)
    if (mDevice.wait(Until.hasObject(firstAccountSelector), UI_TIMEOUT)) {
        // Click first account
        mDevice.findObjects(firstAccountSelector).get(0).click();

        // Button with the text "OK" (enabled)
        BySelector okButtonSelector = By.clazz(CLASS_BUTTON).text("OK").enabled(true);

        // Click OK on account picker
        Assert.assertTrue(mDevice.wait(Until.hasObject(okButtonSelector), UI_TIMEOUT));
        mDevice.findObject(okButtonSelector).click();
    }

    // Check that we can see the title and message
    String titleText = mContext.getString(R.string.invitation_title);
    String messageText = mContext.getString(R.string.invitation_message);

    BySelector titleTextSelector = By.text(titleText);
    BySelector messageTextSelector = By.text(messageText);

    assertTrue(mDevice.wait(Until.hasObject(titleTextSelector), UI_TIMEOUT));
    assertTrue(mDevice.wait(Until.hasObject(messageTextSelector), UI_TIMEOUT));

    // Back out of the dialog
    mDevice.pressBack();
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:39,代码来源:UiAutomatorTest.java

示例15: testSettingsCancel

import android.support.test.uiautomator.BySelector; //导入依赖的package包/类
public void testSettingsCancel() {
    mMenuHelper.assertPressOptionsSettings();
    BySelector byChannelSourcesSidePanel = mSidePanelHelper
            .bySidePanelTitled(R.string.settings_channel_source_item_customize_channels);
    assertWaitForCondition(mDevice, Until.hasObject(byChannelSourcesSidePanel));
    mDevice.pressBack();
    assertWaitForCondition(mDevice, Until.gone(byChannelSourcesSidePanel));
    assertHas(mDevice, Constants.MENU, false);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:10,代码来源:LiveChannelsAppTest.java


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