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

143
Views
set value from 0 to 100 for slider in cypress

I want to drag my slider from different position on every run. My code is

it.only("Changing slider", () => {
        cy.get(':nth-child(4) > .element-list > .menu-list > #item-3').click() //Slider
        cy.get(".range-slider")
        .invoke("val",0-100)
        .trigger("change")
        .click({ force: true })
      })
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are looking to inject a random value into input.value.

With a range 0 - 36, Math.random() * 36 gives you a value in that range.

it("Changing slider", () => {
  cy.get(':nth-child(4) > .element-list > .menu-list > #item-3').click() //Slider

  const randomVal = Math.floor(Math.random() * 36)

  cy.get(".range-slider")
    .invoke("val", randomVal)
    .trigger("change")
    .click({ force: true })
})

BTW - your question title says 0 - 100 but the sample code says 0 - 36 so whichever is your maximum value, substitute it into the code above.

about 4 years ago · Santiago Trujillo 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!