Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

271
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda