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
From the course: End-to-End JavaScript Testing with Cypress.io
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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Installing and opening Cypress3m 38s
-
(Locked)
Writing your first Cypress test5m 3s
-
(Locked)
Testing text input6m 59s
-
(Locked)
Selecting elements8m 35s
-
(Locked)
Aliasing elements4m 24s
-
(Locked)
Working with command results3m 14s
-
(Locked)
The "beforeEach" hook2m 10s
-
(Locked)
Setting a base URL1m 32s
-
-
-
-