Skip to main content

Cypress log Command

If a message needs to be printed for our reference in the command log of cypress, then the log command is used.


cy.log(message, args...)

Arguments used in log command


  • Used to print the message needed to cypress command log.
  • This accepts a markdown formatted message.


  • Additional arguments are to be printed in the log.
  • Many arguments can be used here, and there is no limit.

Cypress Log Correct Use:

cy.log('Clone Jutsu')

This will print the string 'Clone Jutsu'

  • cy.log() yields null when used.
  • It cannot be chained further with any other command.
  • It can only be chained off with the cy.
  • It cannot have any assertions chained.
  • The log cannot timeout.


Let us see a sample example of arguments mentioned in action:


cy.log('visit successful')

Prints the message 'visit successful' in the cypress command log.


cy.log('hokages', ['Minato', 'Saru', 'Naruto'])
  • Prints with the arguments and the message.

Let us see a simple realtime log use example:

describe('Automate AutoPract',()=>{
    it('Should load the url',()=>{
        cy.log('Website Visited Successfully')
    it('Should close POPUP',()=>{
        cy.log('Popup Closed')

    it('Should click Side bar and get last item text',()=>{
        cy.get('#sub-menu').find('li').last().then($log => {
            const fLog = $log.text()

  • Here we used logs to print a message and print an object having a text.
  • We extracted the text from an element and stored it in a variable fLog.
  • And we logged the fLog.

Submitted by arilio666 on February 10, 2022

Ashwin is working with iVagus as a Technical Lead. He has experience in various technologies like Cypress, JavaScript, TypeScript, Rest Assured, Selenium, Cucumber, and Java.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.