feat(playwright): add selectDate & selectTime

This commit is contained in:
Wing-Kam Wong
2022-12-03 20:07:57 +08:00
parent 8a84ad6838
commit 8d85fe2063

View File

@@ -20,14 +20,38 @@ export class DateTimeCellPageObject extends BasePage {
});
}
async selectDateTime({
async selectDate({
// date in format `YYYY-MM-DD`
// time in format 'HH:mm'
dateTime,
date,
}: {
dateTime: string;
date: string;
}) {
await this.rootPage.locator(`td[title="${dateTime}"]`).click();
await this.rootPage.locator(`td[title="${date}"]`).click();
}
async selectTime({
// hour: 0 - 23
// minute: 0 - 59
// second: 0 - 59
hour,
minute,
second,
}: {
hour: string;
minute: string;
second?: string;
}) {
await this.rootPage
.locator(`.ant-picker-time-panel-column:nth-child(1) > ant-picker-time-panel-cell:nth-child(${hour})`)
.click();
await this.rootPage
.locator(`.ant-picker-time-panel-column:nth-child(2) > ant-picker-time-panel-cell:nth-child(${minute})`)
.click();
if (second != null) {
await this.rootPage
.locator(`.ant-picker-time-panel-column:nth-child(3) > ant-picker-time-panel-cell:nth-child(${second})`)
.click();
}
}
async close() {