简体   繁体   中英

selecting a calendar dropdown in cypress

i have a calendar widget in start date field. I would like to select the date in cypress using the cssSelector,how can we do that? The HTML is attached below for reference:

==$0 "Start Date" *

First you have to switch to calender window then you can select the date. Below is the sample code snippet.

cy.get(startDate).click()//click start date
cy.get(calenderPopup)//it will read all dates in the calender
    .each(($el) => {
        var date = $el.text()
        if (today == date) {
            cy.wrap($el).click()
        }
    })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM