XCTest UI "failure fetching values for element" error when using adjustToNormalizedSliderPosition on UISlider

My UI testing has started failing when testing 2 sliders on 1 view in my application (All the other work). It's not an error in my code causing the problem, the slider can be adjusted manualy, and the underlying code is tested too. This only started happening after a recent XCode update, (I think 1 or 2 releases ago). Before that the testing executed without error.


These 2 slider sit in 2 seperate uitableviewcells in a static UITableview, which I suspect to be the problem somehow. All the other sliders in the application are built straight into their views with no tableview.


The error is : failed: Failure fetching attributes for element <XCAccessibilityElement: 0x6100002402d0> Device element: Error Domain=XCTDaemonErrorDomain Code=13 "Value for attribute 5011 is an error." UserInfo={NSLocalizedDescription=Value for attribute 5011 is an error.}


The offending testing code is :

    XCUIElementQuery *tablesQuery = app.tables;
->[tablesQuery.sliders[@"Mask threshold slider"] adjustToNormalizedSliderPosition:0.2];


If I set a breakpoint on the error line, I can go into lddb and see that indeed the slider can be found :

(lldb) po tablesQuery.sliders[@"Mask threshold slider"]
    t =    31.84s     Snapshot accessibility hierarchy for Serious-Cyrus.Reality-Augmenter-iOS
    t =    32.21s     Find: Descendants matching type Table
    t =    32.21s     Find: Descendants matching type Slider
    t =    32.22s     Find: Elements matching predicate '"Mask threshold slider" IN identifiers'
Attributes: Slider 0x60800017de80: traits: 8589938688, {{100.0, 424.5}, {254.0, 31.0}}, label: 'Mask threshold slider', value: 50%
Element subtree:
→Slider 0x60800017de80: traits: 8589938688, {{100.0, 424.5}, {254.0, 31.0}}, label: 'Mask threshold slider', value: 50%
Path to element:
→Application 0x600000176a40: {{0.0, 0.0}, {375.0, 667.0}}, label: 'Reality Augmenter iOS'
  ↳Window 0x618000361f80: Main Window, {{0.0, 0.0}, {375.0, 667.0}}
   ↳Other 0x618000362100: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
    ↳Other 0x618000362280: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
     ↳Other 0x618000362340: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
      ↳Other 0x6180003624c0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
       ↳Other 0x60800017da00: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
        ↳Other 0x60800017d7c0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}}
         ↳Table 0x600000175900: traits: 35192962023424, {{0.0, 64.0}, {375.0, 554.0}}
          ↳Cell 0x60000017a580: traits: 8589934592, {{0.0, 417.5}, {375.0, 44.0}}, label: 'Mask threshold cell'
           ↳Slider 0x60800017de80: traits: 8589938688, {{100.0, 424.5}, {254.0, 31.0}}, label: 'Mask threshold slider', value: 50%
Query chain:
→Find: Target Application 0x6100000b3320
  Output: {
    Application 0x600000176a40: {{0.0, 0.0}, {375.0, 667.0}}, label: 'Reality Augmenter iOS'
  }
  ↪︎Find: Descendants matching type Table
    Output: {
      Table 0x600000175900: traits: 35192962023424, {{0.0, 64.0}, {375.0, 554.0}}
    }
    ↪︎Find: Descendants matching type Slider
      Output: {
        Slider 0x60800017de80: traits: 8589938688, {{100.0, 424.5}, {254.0, 31.0}}, label: 'Mask threshold slider', value: 50%
        Slider 0x618000362580: traits: 8589938688, {{100.0, 551.5}, {261.0, 31.0}}, label: 'Overlay opacity slider', value: 100%
      }
      ↪︎Find: Elements matching predicate '"Mask threshold slider" IN identifiers'
        Output: {
          Slider 0x60800017de80: traits: 8589938688, {{100.0, 424.5}, {254.0, 31.0}}, label: 'Mask threshold slider', value: 50%
        }

Like I said, this used to work, in previous versions of xcode. It's really frustrating as it's the only error left that I can't get rid of without turning off the test, which I don't feel I should have to do.

I am having the same issue with Xcode 9.0 GM. With table view cells, each cell containing a slider, this error will come up when I try to programmatically slider either slider. If I have two sliders in a normal UIView, the action to slider both sliders work fine. Have you found a fix / filed a bug report to Apple and heard back from them?

I just had another look at this today. I still have the issue too and don't have any resolution. I made a demo project and raised a bug: 35145872.


It's pretty easy to replicate the bug with minimal setup.

I created a demo project that shows the bug. Just run the test.


https://github.com/seriouscyrus/SCAutomatorSliderInTableCellBug


The project is simply a UITableViewController with static cells, with a UISlider and UILabel placed in the UITableViewCell. There's a TableViewController class that simply changes the label to the value of the slider when it's changed.

Thanks for filing a bug report. I filed one myself last week and was marked as dupe. With yours, hopefully this will get raised in priority. Here's mine just for the record 35024797

Mine got marked as a dupe too! We can but hope.

XCTest UI "failure fetching values for element" error when using adjustToNormalizedSliderPosition on UISlider
 
 
Q