In tests, elements' value is shown as empty

Hi everyone, how are you doing?

I’m using a method that asserts that the iOS Date pickerwheel has the expected values (month, day, year). This method has been working up until the last Xcode update but now the assertions fail. They’re basically checking the field value against the expected value in the test:

  def assert_date_pickerwheel(month_value, day_value, year_value)
    assert find_element(:xpath, '//XCUIElementTypeCell[@name="Date"]/XCUIElementTypeOther[2]/XCUIElementTypePickerWheel[1]').value == month_value
    assert find_element(:xpath, '//XCUIElementTypeCell[@name="Date"]/XCUIElementTypeOther[2]/XCUIElementTypePickerWheel[2]').value == day_value
    assert find_element(:xpath, '//XCUIElementTypeCell[@name="Date"]/XCUIElementTypeOther[2]/XCUIElementTypePickerWheel[3]').value == year_value
    find_element(:xpath, '//XCUIElementTypeStaticText[@name="Date"]').click

And the invocation goes like this:


When I explicitly ask the test to print the elements’ value it prints an empty line:

    puts find_element(:xpath, '//XCUIElementTypeCell[@name="Date"]/XCUIElementTypeOther[2]/XCUIElementTypePickerWheel[1]').value    #this gives literally '', I understand it's nil

This is really odd since the Appium Inspector effectively shows the correct value of these elements. I’ve checked the xpath locator (unfortunately in this scenario we didn’t find a better locator, might try class chain in a future refactor) and it’s the exact same path. The element exists and all but the test seems to be incapable to read other than an empty in the element’s value.

Any idea on what might be going and how can I find a fix to it? I’ve tested it on the beta and I’m having the same results.



This could be an XCTest bug. Try to find the parent element first (aka XCUIElementTypeCell[@name="Date"]) and then its descendants in separate requests. The trick is that the root of the search is not the page root but the parent element. also, this way the search itself should be much faster, since the search scope would be limited

OK, now the test is working without me changing anything, like somehow it’s properly reading the values now. I don’t know what made it work. However I have another test that is still broken by this same reason, so :neutral_face:.

I’m gonna play a bit with the elements to see if I can point it somehow different (or maybe I find how it the other test got fixed in the first place).


Hello OctavioN,
On iOS and Appium 15.1
I have encountered a similar issue with the message not being retrieved using the type as value, It returns nil. The appium inspector is able to detect the value but not through the code. I believe this could be a defect. This is the link to the post The value of the element displayed as ‘nil’ though it gets displayed in the inspector