【问题标题】:Frank Test : UIPickerView not Updating Value in Cell弗兰克测试:UIPickerView 不更新单元格中的值
【发布时间】:2014-04-01 00:21:07
【问题描述】:

所以,我有以下日期选择器视图:

这已连接到Date of Birth 单元:

现在,在我的 Frank 测试中,我想移动玻璃杯,然后在文本框中反映最终值。为此,我执行以下操作:

dateValue = "04.11.2002"
dateParts = dateVale.split('.')

for i in 2.downto(0) do
  frankly_map( "view:'UIPickerView' index:0", 'selectRow:inComponent:animated:', dateParts[i].to_i - 1, i, false )
end

所以我们循环遍历这些不倒翁并将它们更改为适当的值。但是,不倒翁的变化不会反映在 UITextBox 中。所以我决定通过点击 UIPickerView 中的任何值来更新它:

touch("view marked:'15'")

但是,这改变了每一个不倒翁!谁能告诉我为什么会发生这种情况以及如何确定日期?

【问题讨论】:

  • +1 表示好的问题格式

标签: ios ruby cucumber bdd frank


【解决方案1】:

这是Java 中的一个方法,我从选择器视图中选择一个值(使用所选选择器值的UITextField 也会更新,因为您必须生成滚动事件):

/**
 * Select row with @rowValue value for @selector UI picker view.
 *
 * @param selector
 * @param rowValue
 * @throws Exception
 */
public static void selectRowFromPicker(String selector, String rowValue) throws Exception {
    int component = 0;
    JSONArray rowsCountArray = Frank.frankly_map(selector, "numberOfRowsInComponent:", component);
    if (rowsCountArray.length() == 0) {
        throw new Exception("No rows for picker view component " + component + " were found.");
    }

    int rowsCount = rowsCountArray.getInt(0);
    String tableViewSelector = selector + " descendant tableView";
    boolean found = false;
    String initialText = "";

    for (int i = 0; i < rowsCount; i++) {
        JSONArray array = Frank.frankly_map(selector, "selectRow:inComponent:animated:", i, component, true);
        if (array.length() == 0) {
            throw new Exception("Could not select row from picker view with row value: '" + rowValue + "' selector: '" + selector + "'");
        }
        String labelSelector = tableViewSelector + " descendant label index:0";
        WaitHelper.waitFor(WaitHelper.not(WaitHelper.viewTextToHaveValue(labelSelector, initialText)), GlobalVariables.MEDIUM);
        JSONArray currentTableViewRowValue = Frank.frankly_map(labelSelector, "text");
        if (currentTableViewRowValue.length() == 0) {
            throw new Exception("Could not get the text for current row for picker view selector: " + selector);
        }
        if (currentTableViewRowValue.getString(0).equals(rowValue)) {
            found = true;
            break;
        }
        initialText = currentTableViewRowValue.getString(0);
    }

    //Need to generate a scroll event to bind data in the controls which use the picker selected value
    if (!Frank.scrollDownRows(tableViewSelector, 0) || !found) {
        throw new Exception("Could not scroll down in the picker view selector: " + selector);
    }
}

Frank.scrollDownRows 在哪里:Frank.frankly_map(selector, "scrollDownRows:", noOfRows);

我希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多