1.包含(include)
cy.url().should('include','mp_blog') //当前url包含有mp_blog(如当前正在csdn创建编辑文档的网址为“https://mp.youkuaiyun.com/mp_blog/creation/editor”)
cy.get('.two').should('include.text','测试') //针对文本
2.元素可见(visible)
cy.get('button').should('be.visible') //元素是否可见,比如某些下拉,未展开时display:none
cy.get('button').should('not.be.visible')
3.存在(exist)
cy.get('#loading').should('not.exist') //判断元素是否存在,一般是拿来作为操作是否执行的前置条件
cy.get('#loading').should('exist')
4.包含(contain)
cy.get('.one').should('contain','这是一个测试') //反之为not.contain
等同于:cy.get('.one').contains('这是一个测试')
5.css样式(hava.css)
cy.get('.completed').should('have.css','text-decoration') //多个样式的继续后面,‘样式2’,‘样式3’
6.class类
cy.get('form').find('input').should('not.hava.class','disabled')
cy.get('form').should('have.class','disabled')
7.值(value)
cy.get('option').should('have.value','Lily') //断言当前值是Lily,否为not.have.value
比如,cy.get('#user').type('Cypress').should('have.value', 'Cypress').clear().should('have.value', '')
//输入框输入Cypress,断言值输入成功,清除后断言为空
8.等于(eq)
<div class="title">
<h2>系统设置</h2>
</div>
cy.title().should('eq','系统设置')
9.选中(be.checked)
cy.get(':radio').should('be.checked')
待补充...