本文整理汇总了Java中com.android.uiautomator.core.UiObject.getText方法的典型用法代码示例。如果您正苦于以下问题:Java UiObject.getText方法的具体用法?Java UiObject.getText怎么用?Java UiObject.getText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.uiautomator.core.UiObject
的用法示例。
在下文中一共展示了UiObject.getText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import com.android.uiautomator.core.UiObject; //导入方法依赖的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;
}
示例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: getCurrentMeridiem
import com.android.uiautomator.core.UiObject; //导入方法依赖的package包/类
public static String getCurrentMeridiem() throws UiObjectNotFoundException {
UiObject meridiem = new UiObject(new UiSelector().className(
android.widget.Button.class.getName()).resourceId(MERIDIEM_ID));
return meridiem.getText();
}