【问题标题】:UIAutomation script for setting textfield values in UItableView用于在 UItableView 中设置文本字段值的 UIAutomation 脚本
【发布时间】:2015-08-14 16:44:08
【问题描述】:

我是 UIAutomation 的新手,我正在尝试向 UITabelView 中的两个文本字段输入值。

我试过的脚本如下

var target = UIATarget.localTarget();

var app = target.frontMostApp();

var window = app.mainWindow();

target.delay(1);

var tableView = window.tableViews()[0];

tableView.logElementTree();

var cellOne = tableView.cells()[0].textFields()[0].setValue(“username”);
var cellTwo = tableView.cells()[1].textFields()[0].setValue(“password”);

第一个单元格中的文本字段总是被输入,但第二个总是失败。当我尝试记录其元素树时,它返回 UIElementNil

我的脚本有问题吗?

【问题讨论】:

    标签: javascript ios xcode instruments ui-automation


    【解决方案1】:

    我浏览了 Apple 关于自动化 UI 测试的文档,并按照将手动用户界面操作记录到自动化脚本中,仪器根据我的手动操作为我创建了脚本。

    如果有人像我一样被震惊和愚蠢地不阅读 Apple 的文件。请不要这样做,并始终首先参考 Apple 的文档。

    这是参考

    https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/UsingtheAutomationInstrument/UsingtheAutomationInstrument.html

    这是我的脚本

    var target = UIATarget.localTarget();
    
    var app = target.frontMostApp();
    
    var window = app.mainWindow();
    
    window.buttons()["Login"].tap();
    
    target.delay(1);
    
    var tableView = window.tableViews()[0];
    
    tableView.cells()[0].textFields()[0].textFields()[0].setValue("username");
    
    tableView.cells()[1].secureTextFields()[0].secureTextFields()[0].setValue("password");
    
    window.navigationBar().rightButton().tap();
    

    如您所见,我没有注意到密码文本字段是安全文本字段。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 1970-01-01
      相关资源
      最近更新 更多