【发布时间】:2021-05-22 15:41:45
【问题描述】:
我是赛普拉斯的新手。有一个功能可以检查在日历中创建的一些事件 查看。
如果我选择了每月活动,那么我将在日历中获得 12 个活动 (即;获得文本“我的事件”的#table span.fc-title 的计数将是 12。 并且每次我需要单击日历中的下一个按钮以转到下个月视图)。
我希望在 cypress 中编写一个方法来验证此功能。
这是逻辑:
文本“我的活动”在当前月份是否可见(执行 12 次){
If yes, add 1 to the constant count and click on the next button and navigate to the next month and do the step1
If the text is not found, exit the loop.}
我刚刚设法编写了以下代码。但是任何人都可以请查看这个和 帮我完成这个?我想循环直到找不到文本“我的事件”
常量计数=1; 常量 i = 12;
cy.get('#table span.tc-title')
.each(($span, i) => {
const text = Cypress.$($span).text()
if (text.includes('my event')) {
const count= count+1
cy.get('#table button.tc-next-button').click
//if the text is not there I need to exit the loop;
// I need the value of the count of events too;
return false;
}
})
【问题讨论】:
标签: loops text calendar cypress each