From the course: End-to-End JavaScript Testing with Cypress.io

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with command results

Working with command results

From the course: End-to-End JavaScript Testing with Cypress.io

Start my 1-month free trial

Working with command results

- [Instructor] So now that we've seen the main way of aliasing in Cypress, we're going to look at another way that we can alias elements. But before we do that, let's duplicate this aliasing file. And we'll rename it something like results.spec.js. So, previously I mentioned that there's a way that we can get and work with the results of our cypress commands. For example, if we want to use the result of this cy.get command here. Rephrase. For example, if we want to use the result of this cy.get command here, if we want to have a reference to that element. And the way we do that, we're just going to use this command as an example. So, delete these two things. Is by using the then command in Cypress, which looks like this: .then, and then dollar sign, chars-left-span. And this is going to be a function. And this chars-left-span variable that we have here, is the DOM element that our Cypress command returned to us.…

Contents