zoukankan      html  css  js  c++  java
  • uiautomator使用中文参数

    在上一篇中写了如何用uiautomator去查找界面元素,但对我所在项目的实际运用中,最常用的方式是用匹配控件的的text,然后控件text常常是中文。这时在命令行中获取的中文就会是乱码。解决思路:调用时将中文编码,在jar中获取到参数时将中文解码。
     
     
    Python掉jar包执行命令是需要将中文的编码格式转化为urlencode,注意text后面有空格
    # -*- coding:utf-8 -*-
    import os
    import urllib

    s = urllib.quote('应用')

    cmd = 'cmd.exe /k adb shell uiautomator runtest test.jar -c findObject.findUiobject -e text ' +s

    os.system(cmd)
    java接收到的参数时需要解码,用URLDecoder.decode()
     
     try {
    String textString = URLDecoder.decode(paramName.getString("text"),"UTF-8");
    UiObject idButton3 = new UiObject(new UiSelector().textMatches(textString));
  • 相关阅读:
    git更新代码
    git标签
    git分支
    命令连接redis
    sql语句
    rm -rf无法删除文件解决方法
    lombda 使用记录
    centos查看磁盘空间大小
    CentOS7 防火墙Firewall常用命令
    安装rabbitmq
  • 原文地址:https://www.cnblogs.com/noodles1/p/5477978.html
Copyright © 2011-2022 走看看