Unable to set value for a Datepicker in a UWP app using Appium

Hi,

I am trying to set date on a datepicker control for a UWP application with below C# code:

Approach #1 :
WindowsElement datepicker = AppDriver.FindElementByClassName(“DatePicker”);
datepicker.SendKeys(“03/05/2013”);
AppDriver.FindElementByAccessibilityId(“AcceptButton”).Click();

Approach #2:

Tried setting values for date, month and year individually:

WindowsElement day = AppDriver.FindElementByXPath("//attribute::[contains(., ‘Day’)]/…");
day.SendKeys(“20”);
WindowsElement month = AppDriver.FindElementByXPath("//attribute::[contains(., ‘Month’)]/…");
month.SendKeys(“2”);
WindowsElement year = AppDriver.FindElementByXPath("//attribute::*[contains(., ‘Year’)]/…");
year.SendKeys(“2014”);
AppDriver.FindElementByAccessibilityId(“AcceptButton”).Click();

Both the code snippets above does not throw any exception but fails to set date on the control. Is sendkeys() the right API to set date on datepicker or should it be done differently?
Is setting datepicker value for UWP supported by winappdriver at this point?

Thanks,
Nidhi

Did you tried with setValue??

Is setValue() API available for UWP?
I could find only SetImmediateValue() instead which doesnt seen to be supported by appium for UWP.
I see below error on appium server when using SetImmediateValue()

[WinAppDriver] [STDOUT] {“status”:9,“value”:{“error”:“unknown command”,“message”:“Command not recognized: POST: /session/F7B266C3-537A-43D8-AC36-E999AA7C10CA/appium/element/42.4064534.2.53/value”}}
[MJSONWP] Encountered internal error running command: {“jsonwp”:{“status”:9,“value”:{“error”:“unknown command”,“message”:“Command not recognized: POST: /session/F7B266C3-537A-43D8-AC36-E999AA7C10CA/appium/element/42.4064534.2.53/value”}}} ProxyRequestError: Could not proxy command to remote server. Original error: 404 - {“status”:9,“value”:{“error”:“unknown command”,“message”:“Command not recognized: POST: /session/F7B266C3-537A-43D8-AC36-E999AA7C10CA/appium/element/42.4064534.2.53/value”}}
at JWProxy.proxy$ (C:\Users\nxm0820\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:144:13)
at tryCatch (C:\Users\nxm0820\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\nxm0820\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\nxm0820\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\nxm0820\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] ← POST /wd/hub/session/400562c5-8e13-4bba-867d-58ddb9d7abc3/appium/element/42.4064534.2.53/value 500 9 ms - 236

There is an example here: https://github.com/Microsoft/WinAppDriver/blob/master/Tests/UWPControls/DatePicker.cs

Here is my code:

    private static void SetDayPickerValue(WindowsElement datePicker, string day, string month, string year) {
      // From https://github.com/Microsoft/WinAppDriver/blob/master/Tests/UWPControls/DatePicker.cs
      datePicker.Click();
      var datePickerFlyout = _session.FindElementByAccessibilityId("DatePickerFlyoutPresenter");
      Assert.IsNotNull(datePickerFlyout);

      var monthLoopingSelector = datePickerFlyout.FindElementByAccessibilityId("MonthLoopingSelector");
      monthLoopingSelector.FindElementByName(month).Click();

      var yearLoopingSelector = datePickerFlyout.FindElementByAccessibilityId("YearLoopingSelector");
      yearLoopingSelector.FindElementByName(year).Click();

      var dayLoopingSelector = datePickerFlyout.FindElementByAccessibilityId("DayLoopingSelector");
      dayLoopingSelector.FindElementByName(day).Click();
      datePickerFlyout.FindElementByAccessibilityId("AcceptButton").Click();
    }