Search code examples
detox

How to test DatePickerIOS


I need to enter a day using the native IOS DatePicker. How do I spin the control wheel to a certain value that might not be in the view, since this starts out with the current date?

enter image description here


Solution

  • Detox 7.3.x supports interaction with iOS UIPickerView. Match UIPickerView by type, and interact with it.

    await expect(element(by.type('UIPickerView'))).toBeVisible();
    await element(by.type('UIPickerView')).setColumnToValue(1,"6");
    await element(by.type('UIPickerView')).setColumnToValue(2,"34");
    

    Docs are here: https://github.com/wix/detox/blob/master/docs/APIRef.ActionsOnElement.md#setcolumntovaluecolumnvalue--ios-only