zoukankan      html  css  js  c++  java
  • Appium appium 点击键盘上的 “搜索” 键的方法

    首先我安装的是搜狗输入法,其它的输入法没有去尝试,有兴趣的朋友可以去试一下。(微信APP)

    先去cmd中查看一下你的真机中的输入法

    cmd中输入 adb shell ime list -s

     

    然后代码中的方法是:

    public void findAccountByKeyboard() throws InterruptedException, IOException{
            Thread.sleep(2000);
            driver.findElementById("com.tencent.mm:id/f_").click();
            driver.findElementByXPath("//android.widget.TextView[@text='Add Contacts']").click();
            driver.findElementByXPath("//android.widget.TextView[@text='Official Accounts']").click();
            driver.findElementByXPath("//android.widget.EditText[@text='Search Official Accounts']").sendKeys("*****服务号");       
            Thread.sleep(3000);
    //      driver.pressKeyCode(66);
    
            excuteAdbShell("adb shell ime set com.sohu.inputmethod.sogou/.SogouIME");
            //再次点击输入框,调取键盘
            driver.findElementByXPath("//android.widget.EditText[@text='******服务号']").click();
            //点击右下角的搜索,即ENTER键
            driver.pressKeyCode(AndroidKeyCode.ENTER);
    
        }
    
    /**
         * 执行adb命令
         * @param s 要执行的命令
             */
            private void excuteAdbShell(String s) {
            Runtime runtime=Runtime.getRuntime();
            try{
                runtime.exec(s);
            }catch(Exception e){
                System.out.println("执行命令:"+s+"出错");
            }
        }
  • 相关阅读:
    tomcat启动报错host-manager does not exist
    jq对象,js对象,dom对象的转化
    Axure
    css盒子垂直居中
    数组去重个人总结的六种方式
    原生Ajax
    tp5总结(四)
    tp5总结(二)
    tp5总结(三)
    tp5总结(一)
  • 原文地址:https://www.cnblogs.com/ht22ht22/p/8761718.html
Copyright © 2011-2022 走看看