zoukankan      html  css  js  c++  java
  • Appium总结

    运行case前,最好在case前加入等待,以免activity还未关闭,就开始定位或其他操作(如果case总报错,则考虑此问题);

    swipe效果:

            Thread.sleep(2000);
            int width = driver.manage().window().getSize().width;
            int height = driver.manage().window().getSize().height;
            driver.swipe(width * 3 / 4, height / 2, width / 4, height / 2, 500);
            Thread.sleep(1000);
            driver.swipe(width * 3 / 4, height / 2, width / 4, height / 2, 500);


    实现输入中文的方法:

            capabilities.setCapability("unicodeKeyboard", "True");
            capabilities.setCapability("resetKeyboard", "True");


    xpath定位:

           //相对定位

            WebElement el = driver.findElement(By.xpath("//android.support.v7.widget.RecyclerView/child::android.widget.RelativeLayout/android.widget.TextView[1]"));

           //绝对定位
            WebElement element = driver.findElement(By.xpath("//android.widget.ImageButton[contains(@content-desc,'转到上一层级')]"));
           //相对定位
            WebElement element1 = driver.findElement(By.xpath("//android.widget.TextView[contains(@text,'热门推荐')]/parent::android.widget.RelativeLayout/following-sibling::android.widget.FrameLayout[1]/"
                    + "android.widget.RelativeLayout/child::android.widget.TextView[3]"));


    自动化测试时,可以录制测试视频且保存在手机设备:

            Runtime rt = Runtime.getRuntime();
            // this code for record the screen of your device
            rt.exec("cmd /C adb shell screenrecord /sdcard/test2.mp4");



  • 相关阅读:
    数据库主键生成策略
    弹出窗返回数据实体对象或对象集
    我的家乡话,模糊和清晰的记忆......
    曾经年少
    获取父页面URL的参数对应值及左对齐字符串
    .Net编程规范
    DBdifference
    GridView翻页时保持CheckBox选择状态
    .CS中的javascript
    (转)程序员职业规划
  • 原文地址:https://www.cnblogs.com/wuyepiaoxue/p/5661191.html
Copyright © 2011-2022 走看看