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

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

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 Report

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 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!