Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Basic Commands in Cypress

Category: Cypress
//element is visible & enabled
cy.get('#username').should('be.visible').and('be.enabled')
//element is checked
cy.contains('Checkbox').and('be.checked')

//checks element having class attribute chkbox
cy.get('.checkbox').check()

//obtains children of element n
cy.get('n').children()

//removes input abc
cy.get('#text').type('abc').clear()

//clear abc cookie
cy.clearCookie('abc')

//clear all cookies
cy.clearCookies()

//clear all local storage
cy.clearLocalStorage ()

//click on element with id username
cy.get('#username').click()

//returns element in #txt having HireQA text
cy.get('#txt').contains('HireQA')

//double clicks element with id submit
cy.get('#submit').dblclick()

//pause to debug at start of command
cy.get('#txt').debug()

//It obtains window.document on the active page.

cy.document()

//iterate through individual li
cy.get('li').each(() => {...})

//obtain third td in tr
cy.get('tr>td').eq(2)

//obtain td from tr
cy.get('tr').find('td')

//obtain first td in tr
cy.get('tr>td').first()

//obtain all td from tr in list
cy.get('tr>td')

//It obtains a particular browser cookie by its name.

cy.getCookie('abc')

//It obtains all the cookies

cy.getCookies()

//navigate back
cy.go('back')

//navigate forward
cy.go('forward')

//It launches an URL.

cy.visit('https://www.hireqa.co.in')

//Wait for a certain time in milliseconds
cy.wait(1000)

//It obtains the document title of the active page.

cy.title()

//It prints the messages to the Command Log.

cy.log('Cypress logging ')

//It is used for page reloading.

cy.reload()

Leave a Reply

Your email address will not be published. Required fields are marked *