From the course: End-to-End JavaScript Testing with Cypress.io
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Element aliasing
From the course: End-to-End JavaScript Testing with Cypress.io
Element aliasing
- [Instructor] All right, so at this point we've refactored our Cypress tests to use selectors that are much more robust than simply using an HTML tag or a CSS class. But especially when you look at things like this, you might find yourself longing for the somewhat more concise appearance of our old tag selectors. Right now our tests are pretty verbose and there are plenty of places where we're doing the exact same command over and over again, like with getting the characters left text doing something like this here, there's really no reason why we should have to type this over and over again. So the good news here is that Cypress provides us with a way of reducing the amount of code needed to perform these simple repetitive selections. And this concept is called aliasing in Cypress. So the way that aliasing works is like this. What we're going to do is we simply need to select something in our application. Usually this is going to be an element, but it doesn't necessarily have to be…
Contents
-
-
-
-
Installing and running Cypress2m 14s
-
Writing and running Cypress tests8m
-
(Locked)
Testing text inputs7m 53s
-
(Locked)
Selecting elements8m 20s
-
(Locked)
Element aliasing6m 39s
-
(Locked)
Working with command results5m 43s
-
(Locked)
Using beforeEach4m 57s
-
(Locked)
Setting a base URL3m 29s
-
(Locked)
Challenge 1: Writing your own tests1m 46s
-
(Locked)
Solution 1: Writing your own tests6m 38s
-
-
-
-