【问题标题】:How to automate a UIPickerView to select particular item using KIF?如何自动化 UIPickerView 以使用 KIF 选择特定项目?
【发布时间】:2015-11-24 06:57:27
【问题描述】:

我有一个 UIPickerView 显示一些数字 [4,5,6,7,8]。我想自动化选择器视图以选择数字 6。为此我正在尝试使用以下代码。

tester().tapViewWithAccessibilityLabel("height field")// picker view is input view for the text field
tester().waitForViewWithAccessibilityLabel("size picker")
tester().selectPickerViewRowWithTitle("6")

但测试失败并出现错误“uidatepicker 没有预期的列数”。我无法解决这个问题。任何人都可以帮助我解决这个问题。

【问题讨论】:

    标签: ios swift uipickerview xctest kif


    【解决方案1】:

    你应该在这里添加这个:

    - (NSString *)pickerView:(UIPickerView *)pickerView accessibilityLabelForComponent:(NSInteger)component
    {
        return @"height field";
    }
    

    我遇到的问题是,我用过:

    - (NSAttributedString *)pickerView:(UIPickerView *)pickerView attributedTitleForRow:(NSInteger)row forComponent:(NSInteger)component{
    

    代替:

    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
    

    KIF 似乎不支持在 UIPickerView 中选择属性文本

    【讨论】:

    • 最新更新后。它现在还支持属性标题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多