3

There's an XCUIElement my automated test is validating accessibility on but isAccessibilityElement is returning false. I checked the storyboard file and Accessibility has the checkbox marked. I checked the View Hierarchy as I was debugging the app and it is also reporting accessibility as enabled. All of the containing views in the tree going back to the view controller have accessibility disabled. What could cause this discrepancy between what is returned in the code and what is actually true in the app?

enter image description here enter image description here enter image description here enter image description here


Update: A screenshot of Apple's response to the feedback

enter image description here

Jason
  • 808
  • 6
  • 25
  • Why do you need to check the `isAccessibilityElement ` value ? – cesarmarch Jun 14 '19 at 13:52
  • I need to check `isHittable` actually, but `isHittable` seems to return false if the view has the accessibility enabled checkbox unmarked in the storyboard. I wanted to implement a fallback on `exists` in case I can't rely on `isHittable`, so I need to check to see if the element has its checkbox checked in code, which should be the `isAccessibilityElement` flag – Jason Jun 14 '19 at 17:12
  • `isHittable` is false because an UILabel can't be hit, it's not relative to `isAccessibilityElement`. – cesarmarch Jun 14 '19 at 18:07
  • That's not true because if I check the accessibility checkbox in the storyboard, `isHittable` returns true. The same is true for a UIImageView – Jason Jun 14 '19 at 19:10
  • Are you creating story board from component or using parent class if yes then it should be enable at that level. I had similar problem – N.. Jun 18 '19 at 07:24
  • The ViewController for the storyboard does have a parent, but the parent doesn't set any accessibility parameters. Are you saying I need to enable isAccessibilityElement inside the parent? – Jason Jun 18 '19 at 17:20
  • While we expect every time we check the mark for Accessibility in storyboard for an element (by the way all input type has this checked by default) to return isAccessibilityElement as true, this is not working. Simple set inside Class code isAccessibilityElement to true / false will solve your problem. This is because we want sometime an element to not be counted on by voice over for example. More safe to control this from code. – ares777 Jun 19 '19 at 13:59

1 Answers1

1

I've filed an Apple Feedback request for this issue and will update this answer if I receive a reply

Edit - Apple was kind enough to tell me that this "works as expected" with no further explanation

Jason
  • 808
  • 6
  • 25
  • did you manage to solve it somehow? – Oridadedles Jul 21 '22 at 12:30
  • I added another build configuration strictly for automation with a flag called AUTO, then I used `if #AUTO` in the view controller code to enable accessibility manually for that configuration. Very hacky, it got the job done but I felt dirty. I'll add a picture of Apple's response to the original question – Jason Jul 24 '22 at 07:11