本文整理汇总了Java中com.android.uiautomator.core.UiObject.setText方法的典型用法代码示例。如果您正苦于以下问题:Java UiObject.setText方法的具体用法?Java UiObject.setText怎么用?Java UiObject.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.uiautomator.core.UiObject
的用法示例。
在下文中一共展示了UiObject.setText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDemo
import com.android.uiautomator.core.UiObject; //导入方法依赖的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で入力しています。"));
}
示例2: 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();
}
示例3: run
import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
@Override
public String run(UiAutomatorTestCase uiAutomatorTestCase, Runtime runtime) {
// TODO use both content-description and text
//UiObject uiObject = new UiObject(new UiSelector().descriptionContains(description));
UiObject uiObject = new UiObject(new UiSelector().textContains(description));
try {
uiObject.setText(value);
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
return e.getMessage();
}
return null;
}