Cypress学习5- Assertions断言使用(should, expect)
前言 每个测试用例需要加断言,Cypress里面断言常用的有should, expect 隐式断言 .should() 可以使用.should()给当前用例加断言 should('have.class', 'success') 断言元素的class属性值是 'success' should('have.text', 'Column content') 断言元素文本值 'Column content' should('contain', 'Column content') 断言元素文本包含 'Column content' should('have.html', 'Column content') 断言元素html文本'Column content' should('match', 'td') chai-jquery 使用 "is()"检查元素是否与选择器匹配 .invoke('text') .should('match', /column content/i) 文本与正则表达式匹配先使用invoke结合should .contains('text') 文本与正则表达式匹配元素文本包含,这种比上面更好 <table class="table table-bordered assertion-table"> <thead> <tr> <th>#</th> <th>Column