1

I have input from keyboard disabled for a date picker.

<input _ngcontent-c6="" class="form-control ng-untouched ng-pristine 
    ng-invalid" formcontrolname="attractionDate" id="eventdate" 
    *onkeydown="return false"** placeholder="Enter Your Event" 
    type="date" ng-reflect-name="attractionDate" min="2018-03-20">

I have tried sending keys using: productRegistration.attractionDate.sendKeys('07/07/2018');

It is not sending any key nor is generating any error. I have tried all solutions, but none of them click on the UI of the date. Please help!

Image of the calender: Need to click down triangle to set date

David Walschots
  • 12,279
  • 5
  • 36
  • 59
Mancy Saxena
  • 152
  • 6
  • Are you using AngularJS or Angular? Given the `_ngcontent-6` attribute I'm guessing Angular. Please remove the angularjs tag if that is the case. – David Walschots Mar 20 '18 at 10:47
  • @DavidWalschots Yes I am using Angular2, I have removed the tag – Mancy Saxena Mar 20 '18 at 10:50
  • I'm assuming protractor being a testing framework is simulating the user. Therefore, it probably can't set keyboard input on a disabled field. – David Walschots Mar 20 '18 at 10:50
  • @DavidWalschots Is there a work-around to click on the down arrow and have mouse events to select a date? – Mancy Saxena Mar 20 '18 at 10:53
  • I'm not a protractor user. Do you want to test this specific control, or do you want to fill in a form so you can submit and continue? If the latter, then I'd simply set the value of the date control programmatically. Note that the programmatic value of a date input is different from the presentation format, as answered [here](https://stackoverflow.com/questions/7372038/is-there-any-way-to-change-input-type-date-format/9519493#9519493). – David Walschots Mar 20 '18 at 10:57

0 Answers0