【发布时间】:2016-01-25 15:58:51
【问题描述】:
我是 UIautomator 的新手,需要从应用程序中选择“设置”。 这是演示提供的代码:
package Test;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
public class LaunchSettings extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
getUiDevice().pressHome();
UiObject allAppsButton = new UiObject(new UiSelector().description("Apps"));
UiObject appsTab = new UiObject(new UiSelector().text("Apps"));
appsTab.click();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
UiObject settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), "Settings");
settingsApp.clickAndWaitForNewWindow();
UiObject settingsValidation = new UiObject(new UiSelector().packageName("com.android.settings"));
assertTrue("Unable to detect Settings", settingsValidation.exists());
}
}
执行此操作时,它进入“App”并且什么也不做,错误代码如下:
INSTRUMENTATION_STATUS: test=testDemo
INSTRUMENTATION_STATUS_CODE: -1
INSTRUMENTATION_STATUS: stream=
Test results for WatcherResultPrinter=.E
Time: 19.974
FAILURES!!!
Tests run: 1, Failures: 0, Errors: 1
如果有人能指出我做错了什么,我将不胜感激,这是我的第一次,非常感谢任何帮助。
【问题讨论】:
-
你能显示第 58 行是什么吗?
-
其:UiObject settingsApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), "Settings"); settingsApp.clickAndWaitForNewWindow();
标签: android automated-tests android-uiautomator