Search

Basic Cypress commands

Updated: Apr 22, 2021

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')




13 views0 comments

Recent Posts

See All

A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The f

The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.