iOS UI Automation element finds no sub-elements

前端 未结 2 1574
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-06 14:11

I\'m just starting out with UI Automation for my iOS app and am already having trouble. I\'m unable to attach screen shots so I\'ll do my best to describe my scenario.

相关标签:
2条回答
  • 2021-02-06 14:43

    When you set accessibilityLabel for an element and flag it isAccessibilityElement = YES; the subviews of that element are hidden. For automation, you should use accessibilityIdentifier instead of accessibilityLabel and set isAccessibilityElement = NO;

    In your objective C code after physicianCollectionView is rendered, remove the label and accessibility flag and do this instead:

    physicianCollectionView.accessibilityIdentifier = @"PhysicianCollectionParentView";
    physicianCollectionView.isAccessibilityElement = NO;
    

    For last elements in element tree, which do not have sub views, set isAccessibilityElement = YES;

    0 讨论(0)
  • 2021-02-06 14:57

    If you haven't tried it already, you might try adding a delay at the beginning of your script:

    UIATarget.localTarget().delay(3);
    

    I think that it is possible that your app isn't done rendering/animating before the logElementTree() that you have posted above. We add delays at the beginning and between each application transition in our automated testing scripts to ensure that the screen has finished rendering.

    EDIT: After messing around with your setup in a test app, I believe that your issue is that you are enabling Accessibility on the UIView that contains your segmented control. With accessibility disabled on the UIView, I am able to get the UISegmentedControl to show in the element tree, but once I enable it, the UIView then begins displaying as a UIAElement with no children. My suggestion is to disable accessibility for the containing UIView, and only use accessibility for base controls (like buttons, table view cells, or your segmented button control).

    0 讨论(0)
提交回复
热议问题