本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
}
示例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();
}