# Set value of ion-datetime for e2e test

**URL:** <https://forum.ionicframework.com/t/set-value-of-ion-datetime-for-e2e-test/106176>\
**Category:** ionic-v3\
**Created:** [September 21, 2017, 4:17am UTC](https://forum.ionicframework.com/t/set-value-of-ion-datetime-for-e2e-test/106176 "2017-09-21T04:17:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![simonhaenisch](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/simonhaenisch/32/112056_2.png) [@simonhaenisch](https://forum.ionicframework.com/u/simonhaenisch)\
**Post date:** [September 21, 2017, 4:52am UTC](https://forum.ionicframework.com/t/set-value-of-ion-datetime-for-e2e-test/106176/2 "2017-09-21T04:52:00Z")

</div>

This solution is a bit simpler than @chager’s solution:

```auto
describe('something', () => {
  it('should ...', async () => {
    expect(await $('ion-datetime').getAttribute('pickerformat')).toBe('h mm A');
    await pick($('ion-datetime'), 10, 0, 'PM');
    expect($('some-element').isPresent()).toBeTruthy();
  });
});

const pause = t => new Promise(resolve => setTimeout(resolve, t));

const pick = async (datetimeEl, h, m, a) => {
  if (typeof a === 'string') { a = (a === 'PM') ? 2 : 1; }
  m += 1; // 0-59 => 1-60

  // open time picker
  await datetimeEl.click();
  await pause(500);

  // set value for each column
  await [h, m, a].map(async (val, col) => {
    const el = $$('.picker-col').get(col).$(`button:nth-of-type(${val})`);
    await browser.executeScript('arguments[0].click()', el.getWebElement());
  });
  await pause(500);

  // close time picker
  await $('.picker-toolbar-button:not(.picker-toolbar-cancel) button').click();
  await pause(500);
};

```

The pause is necessary because of the animations. But having some kind of direct access to the `ngModel` would still be a lot easier.

---

_[View the full topic](https://forum.ionicframework.com/t/set-value-of-ion-datetime-for-e2e-test/106176)._
