What means > in Cypress

51 Views Asked by At
cy.get('.pass-input-placeholder > .input-wrapper > .error-msg > .msg-body > span')
  .should('contain', 'Invalid password');

Why are the classes separated with ">"? Does it apply only for classes?

1

There are 1 best solutions below

0
On

It means select "the immediate child". It applies for classes, tags, ids, attributes, anything.

So .pass-input-placeholder > .input-wrapper would find this

<div class="pass-input-placeholder">
  <div class="input-wrapper">

but not this

<div class="pass-input-placeholder">
  <div>
    <div class="input-wrapper">

But without > the second HTML will be found as well.

cy.get('.pass-input-placeholder .input-wrapper')  // finds any descendent