2016-05-23 10 views
1

Ich habe eine Picker-Ansicht und möchte 8 - Sohail oder 9 - Sohail, aber ich kann XCElement mit XCUIElementQuery nicht finden. Wenn ich die Methode 'pickerView - viewForRow' zum Definieren unserer eigenen benutzerdefinierten Ansicht außer Kraft setzte, konnte XCUIElementQuery diese nicht finden. Code ist hier für UIPickerView. Ohne overviewing ViewForRow funktioniert es gut.UIPickerView Testfall bricht bei Verwendung von viewForRow

func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { 
    return 1 
} 

func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 
    return 10 
} 

func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 
    var i : String? 
    i = "\(row) - Sohail" 
    return i 
} 
func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 
    print("\(row) - Sohail") 
} 

func pickerView(pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusingView view: UIView?) -> UIView { 

    let pickerLabel = UILabel() 

    pickerLabel.textColor = UIColor.greenColor() 

    pickerLabel.textAlignment = NSTextAlignment.Center 
    pickerLabel.text = "\(row) - Sohail" 
    return pickerLabel 
} 

Und für UI Testfall

func testPicker(){ 

    let app = XCUIApplication() 

//  print(app.pickerWheels.count) 
//  app.descendantsMatchingType(.PickerWheel)["1 - Sohail"].tap() 
//  print(app.pickerWheels.element) 
//  app.pickerWheels.elementBoundByIndex(0).swipeUp() 

    app.pickerWheels.element.adjustToPickerWheelValue("9 - Sohail") 

    sleep(2) 

//  app.pickerWheels["0 - Sohail"].tap() 
//  app.pickerWheels["8 - Sohail"].tap() 

} 

ich diese Fehlermeldung immer bin.

UI Testing Failure - Internal error: unable to find current value '0 - Sohail, 1 of 10' in possible values 0 - Sohail, 1 - Sohail, 2 - Sohail, 3 - Sohail, 4 - Sohail, 5 - Sohail, 6 - Sohail, 7 - Sohail, 8 - Sohail, 9 - Sohail for the picker wheel "0 - Sohail, 1 of 10" PickerWheel

Antwort

0

Das Problem der accessibilityValue der Zeilen in Ihrem Picker ist als „currentvalue“ definiert in den Fehler angezeigt, nicht das, was Sie tatsächlich lesen. Fehlerbericht on OpenRadar here.