Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
Ideal selector for Cypress automation Javascript

I have this HTML code

<li class="menu-level-1">

    <a href="/Public/app/#/calendar">
        <i class="site-menu-icon material-icons">date_range</i>
        <span>
            Calendar
        </span>

    </a>
</li>

I don't know exactly what I need to select in CYPRESS for automation to press the calendar button. I don't have a unique css or id class so I can't isolate it from the rest of the menu items. I only have what is seen in this code.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I think you want to click the element <a href="/Public/app/#/calendar"> since it has the href.

There's lots of ways to target it, the one to use depends on what is unique on the page

cy.contains('a', 'Calendar').click()  // if the word Calendar only appears on this link
cy.get('a[href="/Public/app/#/calendar"]').click()  // specifies by the link itself
cy,get('i.site-menu-icon').parent().click()  // if the icon is the unique thing
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use custom xpath like //*[text()="Calendar"]

If you have found many others on your web page, you can give an index like //*[text()="Calendar"][1] make sure here the index always starts with 1, not 0.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda