我想比较 UI 中的文本和使用 KIF V3.0 从 WebService 获得的内容。我知道如何在 KIF 1.0 中进行比较,但我不知道 KIF V3.0。
对于 V1.0
+(id)stepToverifyOutput:(NSString *) expectedLabel 可访问性:(NSString *)mylabel
{
NSString *description = [NSString stringWithFormat:@"Verify label text for %@",expectedLabel];
return [self stepWithDescription:description executionBlock:^(KIFTestStep *step, NSError **error) {
UIAccessibilityElement *element = [[UIApplication sharedApplication] accessibilityElementWithLabel:mylabel];
BOOL isValid;
UINavigationController *navbar;
UILabel *lblName;
if([element isKindOfClass:[UILabel class]]){
isValid=YES;
lblName = (UILabel *)[UIAccessibilityElement viewContainingAccessibilityElement:element];;
if ([expectedLabel isEqualToString:lblName.text]) {
return KIFTestStepResultSuccess;
}
}else{
isValid=NO;
navbar = (UINavigationController *)[UIAccessibilityElement viewContainingAccessibilityElement:element];;
if ([expectedLabel isEqualToString:navbar.title]) {
return KIFTestStepResultSuccess;
}
}
KIFTestCondition(NO, error, @"Failed to compare the label text: expected '%@', actual '%@'", expectedLabel,(isValid)?lblName.text:navbar.title);
}];
}
请帮帮我。我被困在这个地方。