【发布时间】:2021-09-15 16:40:47
【问题描述】:
我遍历一个表并遍历这些表的数据以比较它们。但是,如果其中一个表数据不匹配,我会尝试使用 break 来防止进一步检查。
我在这里遇到了一个问题,因为中断将在 cy.then 内部发生,这是行不通的。所以现在我正在尝试找到一种方法来允许 cy.then 设置值,然后继续同步检查其他所有内容。
这是我迄今为止尝试过的无济于事
cy...then((body)=>{
for (let row = 0; row < body.length; row++) {
//Body is the table, and we get the table len
for (let col = 0; col < 4; col++) {
//Begin looping thru each row's col and compare
// Here I attempt to create sync code because I want to not continue
// to loop thru all 4 col if one doesnt match
let val;
new Cypress.Promise((resolve)=>{
cy.get('...').eq(row)...eq(col).then((txt)=>{
val = txt
resolve(txt
})
})
//Begin to compare using val and break child loop if needed
}
}
})
我不断将 val 设为未定义。我是柏树的新手,所以任何指针都会很酷。 谢谢。
我尝试过的 pt2: 在 at 中使用 async/await
cy...then(async(body)
并等待 cypress 承诺,收到超时 4000 毫秒错误,将超时增加到 10000 毫秒,但仍然超时。
【问题讨论】:
标签: cypress