DEV Community

John Peters
John Peters

Posted on • Updated on

Cypress II in 20 minutes

In the first post, details were given on how to install and get Cypress running in your new Angular project.

The first question of importance, is "how do we get addressibility to the elements within the Cypress Test?"

Alt Text

Answer: Cy.get('')

cy.get('body').then(function(body){...} 
Enter fullscreen mode Exit fullscreen mode

But notice that to get the children; we must call a function, and not a property. This is because Cypress uses JQuery under the hood. Which means we have to learn a bit about Cypress internals and how it does things.

var firstelement = body.children()[0]
Enter fullscreen mode Exit fullscreen mode

For now, it's probably a good idea to read up on Cypress' How do I get the native DOM reference? .

Notice in the documentation that the results from a Cypress Get have predefined functions for us to use such as then,shoud,to,not,type These are the commands Cypress uses to effect the tests we are about to write.

More to come...
JWP2020

Top comments (2)

Collapse
 
heruujoko_38 profile image
Heru Joko Priyo Utomo

Hi John,
nice article you have there. also can you share how to make the link between your article ( the part one and part 2)

Collapse
 
jwp profile image
John Peters

Click on Read Full, you should see them linked now. Regards....