gpt4 book ai didi

android - 如何通过runtest命令行参数将值传递给uiautomator android中的方法

转载 作者:行者123 更新时间:2023-11-29 14:38:51 27 4
gpt4 key购买 nike

    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 String Clock 我收到错误 it.framework.AssertionFailedError: Method "testAppByName"not found

最佳答案

为了将参数传递给测试用例,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') 将返回您所写的字符串值

关于android - 如何通过runtest命令行参数将值传递给uiautomator android中的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19288402/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com