I've got few elements with titles like this:
template 2021-4-7 9:50:53
template 2021-4-7 10:35:52
template 2021-4-7 10:38:17
template 2021-4-7 9:50:24
template 2021-4-7 11:27:10
template 2021-4-7 11:24:21
and I would like to select the latest one, so I wrote method like this:
Cypress.Commands.add('addLatestTemplateToSheet', () => {
let templateTitle: string;
workbookEditor.leftMenu.templateMenuButton.click();
workbookEditor.leftMenu.templateItem
.each(($templateItem, index) => {
if (index === 0) {
templateTitle = $templateItem.attr('title');
}
else{
if (templateTitle < $templateItem.attr('title')) {
templateTitle = $templateItem.attr('title');
}
}
})
.then(() => {
//next part of code
});
});Unfortunately it does not works, I get the first item from the list. How should I correct my method?
Aucun commentaire:
Enregistrer un commentaire