zoukankan      html  css  js  c++  java
  • Appium-切换输入法

    在实际工作中,可能会使用到切花输入法

    //
    查看系统当前的输入法 adb shell settings get secure default_input_method //获取当下系统的所有输入法 adb shell ime list //获取当前的可用输入法 adb shell ime list -s com.google.android.googlequicksearchbox/com.google.android.voicesearch.ime.VoiceInputMethodService com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME //设置当前的输入法 adb shell settings put secure default_input_method com.sohu.inputmethod.sogou/.SogouIME
    adb shell ime set com.sohu.inputmethod.sogou/.SogouIME
    //获取当前的输入法 adb shell settings get secure default_input_method com.sohu.inputmethod.sogou/.SogouIME //设置当前的输入法 adb shell settings put secure default_input_method com.sohu.inputmethod.sogou/.SogouIME

    通过代码来调用cmd命令,可以通过定义一个方法,可以将该方法放入utils工具包中

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.nio.charset.Charset;
    import org.apache.log4j.Logger;
    
    public class ExcuteAdbShell {
        public static Logger logger = Logger.getLogger(ExcuteAdbShell.class);
    
        public void ExcuteAdbShell() {
    
        }
    
        /**
         * 执行adb命令
         *
         * @param s 要执行的命令
         */
        public void excuteAdbShell(String s) {
            Runtime run = Runtime.getRuntime();
            try {
                Process p = run.exec(s);                  //执行CMD命令
    
                BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream(), Charset.forName("GBK")));
                String lineMes;
                while ((lineMes = br.readLine()) != null)
    //                System.out.println(lineMes);// 打印输出信息
                    logger.info(lineMes);
                //检查命令是否执行失败。
                if (p.waitFor() != 0) {
                    if (p.exitValue() == 1)//0表示正常结束,1:非正常结束
    //                    System.err.println("命令执行失败!");
                        logger.info("命令执行失败");
                }
                br.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
  • 相关阅读:
    为什么我会认为SAP是世界上最好用最牛逼的ERP系统,没有之一?
    被公司的垃圾XG人事系统吓尿了
    【域控管理】父域的搭建
    【域控管理】域控的必要性
    对.net 程序进行源码混淆
    公司消费一卡通“变法”记
    Oracle研究专题:Oracle系统安装与配置
    数据仓库003
    数据仓库002
    数据仓库001
  • 原文地址:https://www.cnblogs.com/bugoobird/p/13842034.html
Copyright © 2011-2022 走看看