I've scenario to automate in cypress, the test case is to set time for signing appointment either from dropdown or by typing time and selecting from dropdown. Can anyone tell please me how to set time.
I tried with different approach of code it din't work to me
cy.get('#appointment-form_appointmentTime li:nth-child(1)').type('time, 10:30pm').click();
cy.get('.ant-select.ant-select-single.ant-select-allow-clear.ant-select-show-arrow.ant-select-open.ant-select-show-search li:nth-child(1)').type('time, 10:30pm').click();
According to your DOM screenshot you should be able to reference the input field of your dropdown, type in and assert some value as follows:
Get input by id:
cy.get('#appointment-form_appointmentTime').clear().type('some date').should('have.value', 'some date');
or alternatively by class:
cy.get('ant-select-selection-search-input').clear().type('some date').should('have.value', 'some date');
I'm not sure why you are using cy.click() on 1. but I assume that you are trying to click on a value in your dropdown. However, to do this you must first select the appropriate dropdown item with another cy.get() and then click on it with cy.click().
I would have provided the sample code for this as well, however the HTML code for your dropdown entries is missing from the question.