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.
Selecting elements
From the course: End-to-End JavaScript Testing with Cypress.io
Selecting elements
- [Instructor] So now that we have some tests written and passing, it's time to talk about a very important topic in Cypress. And to be specific, we need to take a good hard look at what the best way is to select different elements in our tests, right? So far, for simplicity, we've just been using the HTML tag of whatever element we want to select, and I want to make it very clear that in the vast majority of cases, this is just the wrong way to do it, right? You see the problem here is that using the HTML tag like this is extremely dependent on the current state of our app. So to show you what I mean, let's navigate to example three. And what you'll see here is that we have two text inputs instead of one. Now, if we go back to our application and test this thing, what I'm actually going to do is duplicate this file. I'm just going to copy it and paste it here, and we'll change this to something like selecting.cy.js. Well, let's see what happens if all we change is going to the…
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
-
-
-
-