cypress input value code example
Example 1: cypress command return value into variable
beforeEach(() => {
cy.get('button').invoke('text').as('text')
})
it('has access to text', function () {
this.text
})
Example 2: cypress key press
cy.get('input').type('{shift}{alt}Q')
Example 3: cypress type force
cy.get('whatever').type('Test all the things', { force: true });
Example 4: cypress return value from command
function foo() {
return cy.wrap('foo');
}
Cypress.Commands.add('foo', foo);
cy.foo().then(value => console.log(value));