【发布时间】:2021-10-17 12:45:38
【问题描述】:
我的网站中有 ajax 表,该表有很多页面。我的目标是浏览所有行和列,转到下一页并执行以下过程,直到页面结束。我有以下代码:
for(let i = 0; i < 10; i++){
cy.get('tr:has(td)').each(($tr, rowIndex) => { // look at each row individually
cy.wrap($tr)
.find('td') // all cols inside this row
.invoke('slice', 5, 8) // filter to last 3 cols only
.invoke('text') // get all the text in one lump
.then(text => {
if (text.trim() === '') { // after trim(), is all text empty?
console.log(`Row ${rowIndex+1} has three empty cols`)
cy.wrap($tr).find('td').eq(5).click({force: true}) // click the 6th col
cy.wait(4000)
cy.get('.review-modal_textarea_3L5AQ').eq(0).should('be.visible').type(str)
cy.get('.pagination_pagination_2iOOV > :nth-child(4)').click({force: true}) //clicking to the next page
}
我设法浏览了一个页面中的所有行和列,但在进入下一页时遇到问题(它只运行一次)。我认为我的循环有问题。它根本行不通。我有 i
【问题讨论】:
标签: cypress