课程: End-to-End JavaScript Testing with Cypress.io

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution 3: Writing your own tests

Solution 3: Writing your own tests

(upbeat music) - [Instructor] All right, well hopefully you gave this challenge a try. Let's take a look at the solution. So what we're going to do here is, well, what I did anyway is I started off by creating a new test case. I just said it, and then I said something like, you could really choose anything you wanted here, we'll just say something like displays the second input. I chose to just check for existence here. And then what I did is I simply said cy. And here I actually said cy.visit with example-3. And then the next thing that I did here was I just said cy.get. And I looked for all of the inputs on the page, and then I used the filter method in order to filter it down to only the second one. So let's just inspect that here. I'm going to select the input, and sure enough, we see that this one has input-last-name. So let's just filter it by data-cy. There we go, data-cy=input-last-name. And that's really all we need to do there. That filters it down and we should say…

内容