Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!