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 })
})
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.