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


Java UiObject.exists方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: startTSAP

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Makes sure the Tribler Play app is launched on the device and the
 * MainActivity is shown (in portrait mode)
 * 
 * @throws UiObjectNotFoundException
 * @throws RemoteException
 */
protected void startTSAP() throws UiObjectNotFoundException,
		RemoteException {
	UiObject upButton = new UiObject(
			new UiSelector().description("Navigate up"));
	while (!upButton.exists()) {
	}

	// Validate that the package name is the expected one
	UiObject tsapValidation = new UiObject(
			new UiSelector().packageName("org.tribler.tsap"));
	assertTrue("Unable to find Tribler Play app", tsapValidation.exists());

	// Set the rotation to normal (=portrait mode)
	getUiDevice().setOrientationNatural();
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:23,代码来源:BasicUiTestCase.java

示例5: 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

示例6: 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

示例7: hasConversation

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
protected boolean hasConversation() {
	UiSelector firstEl = new UiSelector()
			.className("android.widget.ListView").index(3)
			.childSelector(new UiSelector().index(0));
	UiObject conversation = new UiObject(firstEl);
	return conversation.exists();
}
 
开发者ID:chesterbr,项目名称:vicky,代码行数:8,代码来源:LaunchSettings.java

示例8: chat

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
protected void chat() throws UiObjectNotFoundException {
	// Select First conversation
	UiSelector firstEl = new UiSelector()
			.className("android.widget.ListView").index(3)
			.childSelector(new UiSelector().index(0));
	UiObject conversation = new UiObject(firstEl);
	conversation.clickAndWaitForNewWindow();

	// Reads Text
	UiObject text = new UiObject(find("ListView-2.LinearLayout-2.TextView-0").instance(0));
	String response;
	if (text.exists()) {
		String userInput = text.getText();
		// Get response from the server
		response = getResponseFor(userInput.toString());
	} else {
		response = "What?";
	}

	// Write response back
	UiObject textBox = new UiObject(find("EditText-0"));
	UiObject submitButton = new UiObject(find("LinearLayout-5.ImageView-3"));
	textBox.setText(response);
	submitButton.click();

	// Delete conversation
	UiObject conversarionManager = new UiObject(new UiSelector().className(
			"android.widget.ImageView").instance(2));
	conversarionManager.clickAndWaitForNewWindow();
	UiObject closeButton = new UiObject(find("TextView-3"));
	closeButton.clickAndWaitForNewWindow();
	UiObject confirmCloseButton = new UiObject(find("Button-1"));
	confirmCloseButton.click();
}
 
开发者ID:chesterbr,项目名称:vicky,代码行数:35,代码来源:LaunchSettings.java

示例9: run

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public String run(UiAutomatorTestCase uiAutomatorTestCase, Runtime runtime) {

    // Find a specific String in the screen
    UiObject uiObject = new UiObject(new UiSelector().textContains(value));
    if (!uiObject.exists()) {
        return "value " + value + " not found";
    }
    return null;

}
 
开发者ID:fabricereix,项目名称:AndroidFunctionalTester,代码行数:12,代码来源:AssertExistAction.java

示例10: openNavigationDrawer

import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
/**
 * Helper function that starts the TSAP app and opens the navigation drawer
 * if it isn't opened
 * 
 * @throws UiObjectNotFoundException
 * @throws RemoteException
 */
private void openNavigationDrawer() throws UiObjectNotFoundException,
		RemoteException {
	startTSAP();

	UiObject navDrawer = new UiObject(
			new UiSelector().description("navigation_drawer"));
	if (!navDrawer.exists()) {
		UiObject upButton = new UiObject(
				new UiSelector().descriptionContains("navigation drawer"));
		upButton.click();
	}
}
 
开发者ID:Tribler,项目名称:tribler-android,代码行数:20,代码来源:NavigationDrawerUiTest.java

示例11: testStartLocalServerUsingTestContent

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


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