public void testAppByName(String appName) throws UiObjectNotFoundException {
screenUnlocker();
// String appName = "Clock";
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));
UiObject appLaunch = appViews.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()), appName);
appLaunch.clickAndWaitForNewWindow();
}
如何使用uiautomator runtest命令为方法提供值
我尝试执行以下命令adb shell uiautomator> runtest LaunchAppByName.jar -c> com.motorola.launchappbyname.LaunchAppByName#testAppByName -e字符串Clock我遇到错误it.framework.AssertionFailedError:未找到方法“ testAppByName”
最佳答案
要将参数传递给测试用例,uiautomator表示:
-e <NAME> <VALUE>: other name-value pairs to be passed to test classes.
May be repeated.
例如,您可以执行以下操作:
adb shell uiautomator runtest UiTest.jar -c package.name.ClassName -e stringKey stringValue
在代码中,您可以使用
String stringValue = getParams().getString("stringKey");
getString('key')
将返回您写为stringValue的内容关于android-ui - 如何通过运行测试命令行参数将值传递给uiautomator android中的方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19288402/