Reputation: 353
I defined a new command in "commands.js"
Cypress.Commands.add('subValues', (a, b) => { return a - b });
then I call the new function use follwing code
it('Call new function', function(){
let email = cy.subValues(15, 8);
cy.get('#Email').type(email);
});
but the result instead "7" the result is "[object Object]".
what things I did wrong, please help!
Upvotes: 0
Views: 280
Reputation: 432
To use the value from subject, please resolve it as below
cy.subValues(15, 8).then(x => cy.get('#Email').type(x));
Upvotes: 1