Why cy.log Prints Nothing

1 · Gleb Bahmutov · July 10, 2021, 1:04 p.m.
This is a very common question and comes up at least every couple of days on the Cypress chat channel.Imagine you have an element on the page1<div id="username">Mary</div>You would like to print the text from the element #username to Cypress Command Log. You know that Cypress commands are asynchronous, so you place the value into a variable before calling cy.log command.1234567it('prints the text', () => { cy.visit('index.html') // ⛔️ INCORRECT - PRINTS NULL let username = null cy.get('#user...