如何发送空间文本的Andr​​oid UIAutomator -e命令行参数 [英] How to send text with space in Android UIAutomator -e command line parameter

查看:450
本文介绍了如何发送空间文本的Andr​​oid UIAutomator -e命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何与空间发送文本中的Andr​​oid UIAutomator -e选项(名称 - 值对)

有关例如:

亚行外壳uiautomator的runTest LaunchSettings.jar -c com.uia.example.my.LaunchSettings

我想给像

亚行外壳uiautomator的runTest LaunchSettings.jar -c com.uia.example.my.LaunchSettings -e的appName寺运行

但像收到错误消息:

不支持独立的参数。

试图像神庙逃亡或神庙逃亡,但没有用。

请提示


解决方案

 字符串defaultAppName =我的超级应用;    字符串toAppName = getParams()方法的getString(APPNAME); //通过应用程序名的appName'键    如果(toAppName!= NULL){
        toAppName = toAppName.replace(0,); //在应用名称中使用0而不是空格
        defaultAppName = toAppName.trim();
    }

以上code将默认为我的超级应用,如果没有-e选项(名称 - 值对)进行此测试时通过。

要空间传递参数,如我的超级dooper的应用程序,根据code以上,将要插入每一个空间0的需求。

要通过我的超级dooper应用作为参数传递给上面的code,需要派用场:

  -e APPNAME」my0super0dooper0app

在您的情况:

 亚行外壳uiautomator的runTest LaunchSettings.jar -c com.uia.example.my.LaunchSettings -e的appName Temple0Run

(而不是0就可以将任何字母数字字符作为一个占位符如下面的例子中)

UiAutomator不能理解空间命令行参数,&放大器中,<,>,(,),,,以及一些的Uni code的字符。在这种情况下,人们必须更换一个占位符与所需的符号命令行。

例如:

 如果(toParam!= NULL){
        toParam = toParam.replace(0space0,); //在命令行参数插入0space0为每一个空间
        toParam = toParam.replace(0amper0,与&); //为每一个与放大器命令行参数插入0amper0;
        toParam = toParam.replace(0less0,&下;); //为每&LT命令行参数插入0less0;
        toParam = toParam.replace(0more0,>中); //为每&GT命令行参数插入0more0;
        toParam = toParam.replace(0openbkt0,(); //在每一个命令行参数插入0openbkt0(
        toParam = toParam.replace(0closebkt0,)); //为每一个命令行参数插入0closebkt0)
        toParam = toParam.replace(0onequote0,'); //为每一个命令行参数插入0onequote0
        toNumber = toParam.trim();
    }

I want to know how to send text with space in Android UIAutomator -e option (name-value pair)

For Ex:

adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings

I want to send like

adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings -e appName Temple Run

But getting error message like:

Unsupported standalone parameter.

tried like "Temple Run" or 'Temple Run' but no use.

Please suggest

解决方案

    String defaultAppName = "My super App";

    String toAppName = getParams().getString("appName"); //pass app name with 'appName' key

    if (toAppName != null) {
        toAppName = toAppName.replace("0"," "); //use 0 instead of space in app name
        defaultAppName=toAppName.trim();
    }

The above code will default to 'My super App' if no -e option (name-value pair) is passed when running this test.

To pass the arguments with space, like 'my super dooper app', according to the code above, 0 needs to be inserted for every space.

To pass 'my super dooper app' as an argument to the above code, one needs to send use:

-e appName "my0super0dooper0app"

In your case:

 adb shell uiautomator runtest LaunchSettings.jar -c com.uia.example.my.LaunchSettings -e appName Temple0Run

(Instead of '0' you can insert any alpha numeric character as a placeholder as shown in example below)

UiAutomator fails to understand command line parameters with space, &, <, > , (,) , ", ' , as well as some Unicode characters. In such a case, one has to replace a placeholder in command line with the desired symbol.

example:

if (toParam != null) {
        toParam = toParam.replace("0space0", " "); //insert 0space0 in command line parameters for every space
        toParam = toParam.replace("0amper0", "&"); //insert 0amper0 in command line parameters for every &
        toParam = toParam.replace("0less0", "<"); //insert 0less0 in command line parameters for every <
        toParam = toParam.replace("0more0", ">"); //insert 0more0 in command line parameters for every >
        toParam = toParam.replace("0openbkt0", "("); //insert 0openbkt0 in command line parameters for every (
        toParam = toParam.replace("0closebkt0", ")"); //insert 0closebkt0 in command line parameters for every )
        toParam = toParam.replace("0onequote0", "'"); //insert 0onequote0 in command line parameters for every '
        toNumber = toParam.trim();
    }

这篇关于如何发送空间文本的Andr​​oid UIAutomator -e命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆