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();
            }
        }
    }
  • 相关阅读:
    CS001496 Gather data from web page with JavaScript, WebKit, and Qt
    中文 英特尔® 软件网络 blog
    CS001496 Gather data from web page with JavaScript, WebKit, and Qt
    Qt Port of WebKit ¶
    Category:Qt WebKit Nokia Developer Wiki
    Qt webKit可以做什么(四)——实现本地QObject和JavaScript交互
    看了潘爱民老师的关于smartcache for webkit的paper
    Qt 4.7: QWebInspector Class Reference
    CS001497 Add data to a web page with JavaScript, WebKit, and Qt
    geventcurl
  • 原文地址:https://www.cnblogs.com/bugoobird/p/13842034.html
Copyright © 2011-2022 走看看