Here are the basic commands to interact with webpages in cypress.
1. Visit:
cy.visit("url")
2. Contains:
cy.contains("any text")
3. Get:
cy.get("css selector")
4. should:
User for assertion
cy.contains("any text"). should('exists')
cy.get("css selector).should('have.text' , 'anytext')
cy.should('have.attr' , 'style', 'attribute value')
5. Viewport
cy.viewport(1200*720) //set resolution
cy.viewport("iphone-6") //device setting
6. Log
cy.log("text")
cy.log("text",value)
7. URL
cy.url().should('include','/text')
cy.log('url = ',cy.url())
cy.url().then((value)=>{
cy.log("the current url is",value)
})
8. Type
cy.contains("text").type("any text")
9. Pause
cy.pause
10. TimeOut:
cy.contains('text',{timeout:1*1000}).should('exist')
Comments