Home  >  Q&A  >  body text

How to continue filling out a form with Vue date picker Cypress

<p>I tried filling out the form using cypress. The form is built with Vue and looks like this</p> <p>The problem is, the scheduled date is a date picker that I populate using the cypress type() command. For example</p> <pre class="brush:js;toolbar:false;">cy.get('#dispatch-date').type('22-10-2022'); </pre> <p>However, this is what the form looks like after entering the command</p> <p>The date picker dropdown menu covers the rest of the form, not allowing cypress to continue filling out the form. I tried clicking {enter} after entering the date but it submitted the form. I also tried the {force:true} option but it failed the test because the date picker is actually a <div> instead of an <input> tag. Any ideas how to solve this problem? </p>
P粉141911244P粉141911244416 days ago472

reply all(1)I'll reply

  • P粉561438407

    P粉5614384072023-08-30 13:29:54

    This will depend on the exact date picker you use in your application, or more precisely, how the user interacts with it.

    For example, if it was a vue2-datepicker, you might just close the control to trigger its update.

    cy.get('#dispatch-date')
      .type('{selectAll}22-10-2022')                   // {selectAll} if not empty
      .trigger('keydown', {keyCode: 9, which: 9})
    
    cy.get('#dispatch-date')
      .should('have.value', '22-10-2022')
    

    Note that clicking the element will close the selector, but the value will not be updated to the v-model.

    reply
    0
  • Cancelreply