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

276
Visualizações
Nightwatch - How can I CSS select a nested button with no unique identifiers on the button itself

In image 'UI' I need to select the second 'Setup' button on the page.

I've tried many different combinations of trying to select this element but have had no luck. I've seen some related posts but most talk about having 1 parent and 1 or 2 child elements. In this case I need to go along this path: li2/div2/div/a. I'm just unsure of how to string that together.

Xpath is not an option unfortunately as the id changes from session to session.

UI

Inspecting the DOM

For additional context, the other options in the ul (Google Auth & Voice Auth) are identical to the SMS li.

Ideally, I would want to do something like this, but I feel that I am way off:

selector: 'li[data-se$="SMS"] + a[class$="button link-button"]'
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Why not select by the data attribute?

If you need to "click" on the button, you'll need to decide when that happens. You could for example do it on page load:

const sms = document.querySelector("[data-se='SMS']");
const simulated_button_click = sms.getElementsByClassName('link-button')[0];
<body onload="simulated_button_click.click()">
...
<div class="enroll-factor-list">
    <ul class="list-content">
        <li data-se="GOOGLE_AUTH" class="enroll-factor-row clearfix">
            <div class="enroll-factor-icon-container">
                <div class="enroll-factor-button">
                    <a class="button link-button" href="#">Setup</a>
                </div>
            </div>
      </li>
      <li data-se="SMS" class="enroll-factor-row clearfix">
            <div class="enroll-factor-icon-container">
                <div class="enroll-factor-button">
                    <a class="button link-button" href="#">Setup</a>
                </div>
            </div>
      </li>
  </ul>
</div>
...
</body>

about 4 years ago · Juan Pablo Isaza Relatório

0

I was able to select the button with use of the descendant combinator.

https://www.w3.org/TR/selectors-3/#descendant-combinators

selector: 'li[data-se="SMS"] * a[data-se$="button"]'
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