• API 自动化测试框架分享 at 2015年10月12日

    mark~

  • 赞赞赞!!! 最近正在思考这些东西呢!!!

  • 现在 appium 支持 H5 了~定位 webview 内的元素妥妥的~至少我们的应用没问题~

  • 中文 webdriver API 文档 at 2015年09月06日

    二妹子!!!

  • 还是喜欢 mybatis 多些

  • appium 自动化分享和请教 at 2015年08月18日

    @shixue33 妹子的想法 想借助 django 不过具体的想法可能不一样 再说再说

  • #10 楼 @zsx10110 嗯嗯很喜欢您的学习风格啊大赞~~学习学习了~thx

  • #8 楼 @zsx10110 赞赞赞!!! 不过这种方式我真是没用过 :plus1: 太厉害了 ~!!!

  • #6 楼 @zsx10110

    没有这种用法。
    其实分号不加可以定位到,那就不用加了。定位多个元素 appium 有封装好的方法可以直接用。

  • #3 楼 @zsx10110 关于你的最后一个问题

    private void consumeStatement() throws UiSelectorSyntaxException {
        String statement;
        int index = 0;
        int parenCount = -1; // semicolons could appear inside String arguments, so we make sure we only count occurrences outside of a parenthesis pair
        while (index < text.length()) {
          if (text.charAt(index) == ';' && parenCount == 0) {
            break;
          }
          if (text.charAt(index) == '(') {
            if (parenCount < 0) {
              parenCount = 1;
            } else {
              parenCount++;
            }
          }
          if (text.charAt(index) == ')') {
            parenCount--;
          }
          index++;
        }
    

    driver.findElement(MobileBy.AndroidUIAutomator("new UiSelector().index(0)"));

    你把定位脚本传入得字符串放进去就知道了。
    定义了一个 parenCount=-1 做标示;
    遇到"(" -> parenCount=1
    遇到")" -> parentCount--
    所以 parenCount 最后肯定等于 0。
    而传入的字符串是允许有 “;” 的,只不过只能放在分号外 (semicolons could appear inside String arguments, so we make sure we only count occurrences outside of a parenthesis pair)
    所以也就是在解析字符串时,到了最后一个字符如果是";"就直接 break;如果不是那就 index++,最后也是不符合 while 条件跳出来的~

  • #3 楼 @zsx10110 卧槽! 就是喜欢你这种人! 👏 我先 mark 着~明天再来看你这一段研究啊哈哈哈 😄

    • 定位脚本

      WebElement el = driver.findElementsByAndroidUIAutomator("new UiSelector().className(android.widget.ListView).childSelector(new UiSelector().className(android.widget.LinearLayout).clickable(true))");
      
    • 打开 findElementByAndroidUIAutomator 方法

    @SuppressWarnings("unchecked")
    @Override
    public RequiredElementType findElementByAndroidUIAutomator(String using) {
        return (RequiredElementType) findElement("-android uiautomator", using);
    }
    
    • 再打开 findElement("-android uiautomator", using) // 是 webdriver 的方法
    protected WebElement findElement(String by, String using) {
        if(using == null) {
            throw new IllegalArgumentException("Cannot find elements when the selector is null.");
        } else {
            Response response = this.execute("findElement", ImmutableMap.of("using", by, "value", using));
            Object value = response.getValue();
    
            WebElement element;
            try {
                element = (WebElement)value;
            } catch (ClassCastException var7) {
                throw new WebDriverException("Returned value cannot be converted to WebElement: " + value, var7);
            }
    
            this.setFoundBy(this, element, by, using);
            return element;
        }
    }
    

    大概有点了解了 不过再底层一点的 就没看了

    btw 楼主解析代码 一步步走 真好 很清晰呢 赞赞赞~

  • #49 楼 @laiyuncong8404
    可以把 driver 的实例化封装在一个类方法内~(这是其中的一个方法而已)
    不过如果后期希望做到不同设备不同 driver 跑同一份测试脚本(或者其他并发策略)就要另外对 driver 做其他处理(论坛内有不少帖子实现了并发的功能了)

    #BasePage
    
        //初始化driver
        public AndroidDriver SetDriver() throws MalformedURLException {
            try{
                driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), this.SetCa());
    
            }catch (MalformedURLException e){
                e.printStackTrace();
            }
            return driver;
        }
    
    #DashPage
    
        /**
         * 业务封装
         */
    
        //搜索 - 收藏
        public void Search(String recipe,Class name) throws IOException, InvalidFormatException {
            LoggerControler log = this.MyLogger(name);
            AndroidDriver driver = super.SetDriver();
            this.ClickSearchBox();
            this.InputRecipe(recipe);
            log.info("本次搜索的食材是:"+recipe);
            driver.sendKeyEvent(66);
            this.ClickCollectionItem();
            //this.ClickFavorite();
            log.info("收藏的菜谱名为:"+this.GetRecipeName());
            super.captureScreen("Search_"+recipe);
            Assert.assertTrue(GetRecipeName().contains(recipe));
            log.info("该Case测试通过");
        }
    
  • 谢谢大家的回复和建议 👌

  • #13 楼 @xushizhao 好的。等你的分享 ~

  • #2 楼 @mads 现在的公司平均一个礼拜加 2 天吧。算是我加最多的公司了啊哈哈。如果是上海的新公司的话,加不加班,没有特别所谓了。反正一个人在外地,也就那样了,就是折腾呗。

  • 或许自己不应该考虑这么多的 性格问题伤不起 😩

  • 我表示很崇拜楼主。努力 ing 😄

  • 1.如果一个页面的同一个元素,在同一个 case 中, 不同时间做不同的操作,是写两个,还是定义两个,xml 解析成脚本时在做处理?
    2.你们是用 UIautomator 把页面元素 dump 下来再去编辑修改维护 xml 吗?一个页面一个 xml。你们现在管理编辑起来感觉方便吗?
    3.web 平台上显示的 html 点击运行开始解析脚本跑用例,这挺好的。以后你们的可以平台化了。
    4.谢谢楼主的分享。

  • #47 楼 @louqqson008 appium 暂不支持哦~robotium 可以~appium 未来应该会支持~

  • #45 楼 @louqqson008 嗯。如果你觉得项目合适,可以用这种方式。不过我觉得 PO 不是最优方案。你可以了解下关键字。

  • Facebook/atc 环境搭建总结 at 2015年07月06日

    赞赞赞 不懂 windowns 做热点可以设置吗

  • #42 楼 @very 你是谁呢?

  • #34 楼 @very 认识? 😪

  • #39 楼 @lework 不是。appium 启动只开一个 session。测试集内的是按照你 testcase 顺序跑的。