【问题标题】:Xcode>Instruments>Automation>Mac: is there a way to use regular expression within Automation in InstrumentsXcode>Instruments>Automation>Mac:有没有办法在 Instruments 的自动化中使用正则表达式
【发布时间】:2012-06-18 23:56:59
【问题描述】:

我对 Instruments>Automation 完全陌生。尝试使用 Instruments 中的自动化测试内部应用。

这是我的问题:
我们的应用程序具有动态生成的 UI 单元格。无法预测将创建多少个单元格以及它们将具有什么名称。但是,它们都将包含一个特定的字符串(如“课程”)。问题是 - 如何使用自动化找出特定单元格的名称中是否包含该字符串?

【问题讨论】:

    标签: xcode-instruments


    【解决方案1】:

    您可以简单地使用“长度”属性获得总细胞数。

    var cellsCount = <YourUIATableViewObject>.cells().length;
    UIALogger.logMessage("total cells count = " + cellCount);
    

    之后,您将能够获取单元格属性并使用它们进行操作:

    for (var i = 0; i < cellsCount; i ++)
    {
         var cellValue = <YourUIATableViewObject>.cells()[i].value();
         var cellName = <YourUIATableViewObject>.cells()[i].name();
         UIALogger.logMessage("Cell #"+i+" properties: cellValue ="+cellValue+"; cellName ="+cellName);
    
         //Try to use match() or search() functions to find what you need.
         if ( cellName.search("Courses") != -1 )
         //if (cellValue.search("Courses") != -1 )
         {
              UIAlogger.logMessage("Cell #"+i+" contains 'Courses'");
         }
         else
         {
              UIAlogger.logMessage("Cell #"+i+" does not contain 'Courses'");
         }
    }
    

    这个JavaScript tutorial 会帮助你:

    【讨论】:

      猜你喜欢
      • 2016-12-15
      • 2013-08-01
      • 2013-12-07
      • 1970-01-01
      • 1970-01-01
      • 2014-08-17
      • 2021-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多