0
Я новичок в UIautomator и вам нужно выбрать «Настройки» из приложений. Это код, который демо обеспечивают:UiScrollable не работает в 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? – Ophitect
его: UiObject settingsApp = appViews.getChildByText ( новый UiSelector(). ClassName (android.widget.TextView.class.getName()), «Настройки»); settingsApp.clickAndWaitForNewWindow(); – Anoonymonus