Cypress web自动化5-table表格元素(别名使用Aliasing)
发布日期:2021-05-09 09:02:54 浏览次数:15 分类:博客文章

本文共 1789 字,大约阅读时间需要 5 分钟。

������

������������������������������������������������������������������������������������������������������������������������������������������������������������

.as()������������������������

table������������������������������������

Column 1 Column 2
Row 1: Cell 1 Row 1: Cell 2
Row 2: Cell 1 Row 2: Cell 2

// The following DOM command chain is unwieldy.// To avoid repeating it, let's use `.as()`!cy.get('.as-table')  .find('tbody>tr').first()  .find('td').first()  .find('button').as('firstBtn')// To reference the alias we created, we place an// @ in front of its namecy.get('@firstBtn').click()cy.get('@firstBtn')  .should('have.class', 'btn-success')  .and('contain', 'Changed')

.as() ������������������

���������������������������������������������������������������������������������reponse

������������������������������������������������������������������������������������������������������������������������200

// Alias the route to wait for its responsecy.server()cy.route('GET', 'comments/*').as('getComment')// we have code that gets a comment when// the button is clicked in scripts.jscy.get('.network-btn').click()// https://on.cypress.io/waitcy.wait('@getComment').its('status').should('eq', 200)

QQ������������939110556

上一篇:Cypress web自动化6- Assertions断言使用(should, expect)
下一篇:Cypress web自动化4-操作页面元素(Actions行为事件)

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月07日 05时22分17秒