1 回答

TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊
我認(rèn)為您錯(cuò)過(guò)了一些步驟,因?yàn)榫拖裨诖司W(wǎng)絡(luò)研討會(huì)中一樣,cypress 可以看到在實(shí)現(xiàn)步驟 1 并且加載尚未開始時(shí)頁(yè)面中缺少該元素,因此它給出了誤報(bào)斷言。我對(duì)這種情況的解決方案是向測(cè)試添加更多步驟,而不是使用固定cy.wait()
- 我的步驟如下:
cy.get('.add_to_cart_button').click(); // Step 1
cy.get('.overlay').should( 'be.visible' ); // Needed to see that the process is starting
cy.get('.overlay').should( 'not.be.visible' ); // Needed to see that the process has ended
cy.get('.add_to_cart_button').should( 'have.class', 'loading' ); // Needed to see that the process is starting
cy.get('.add_to_cart_button').should( 'not.have.class', 'loading' ); // Needed to see that the process has ended
cy.visit( Cypress.env( 'baseUrl' ) + '/cart' ); // Step 9
我還建議在 cypress.json 文件中使用以下行:
"defaultCommandTimeout": 60000,
"requestTimeout": 60000,
"responseTimeout": 60000,
添加回答
舉報(bào)