【问题标题】:XCTest Objective C Xcode8.1 how to extract label/value/name of any button or navigator barXCTest Objective C Xcode8.1如何提取任何按钮或导航栏的标签/值/名称
【发布时间】:2016-12-14 06:57:25
【问题描述】:

谁能告诉我如何提取任何按钮或导航栏的标签/值/名称

到目前为止我尝试过的代码

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].title;
NSLog(@"%@++++++++", Test);

和

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].accessibilityLabel;
NSLog(@"%@++++++++", Test);

和

NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].accessibilityValue;
NSLog(@"%@++++++++", Test);

以上所有 3 个的输出保持为空

【问题讨论】:

    标签: objective-c xcode xctest


    【解决方案1】:

    使用label 访问静态文本元素的值。

    NSString *test = app.navigationBars[@"Test"].staticTexts[@"Test"].label;
    NSLog(@"%@++++++++", test);
    

    https://developer.apple.com/reference/xctest/xcuielementattributes/1500692-label

    【讨论】:

      【解决方案2】:

      您必须使用label。对于您的情况,将其替换为:

      NSString *Test = app.navigationBars[@"Test"].staticTexts[@"Test"].label;
      

      【讨论】:

        猜你喜欢
        • 2020-08-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-04-06
        • 2014-12-30
        相关资源
        最近更新 更多