Slide a button
# i-need-help
p
I wanted to slide the below mention button? Is there any better mechanism? I tried something like:
Copy code
javascript
          cy.get('#sliderButton > button')
            .trigger('mousedown', { button: 0, position: 'center' })
            .trigger('mousemove', { clientX: 1000, clientY: 0 })
            .trigger('mouseup', { force: true });

https://cdn.discordapp.com/attachments/1108696607832158329/1108696608012505088/Screenshot_2023-05-18_at_10.59.40.png

a
You can change the slider value directly.
Copy code
cy.get("sliderLocator").invoke('val', maxvalue).trigger('change')
p
@adventurous-whale-33899 I tried it but it didn't work 😦 I tried with the maxvalue - 100 (not sure if this is correct or not) for both the slider as well as the button locators
a
@plain-potato-68806 It's this component right? https://codepen.io/bennettfeely/pen/ndwdGA
It worked for me.
Copy code
cy.get("#confirm").invoke('val', 100).trigger('change').then(() => {
            cy.get('.delete-notice').should('be.visible')
        })

https://cdn.discordapp.com/attachments/1108696607832158329/1109331472550207538/image.png

g
You don’t need cy.then
p
@adventurous-whale-33899 I tried it on the actual application where we enhanced this component. For example, in this sample site, the component type is input (
<input id="confirm"
) whereas in my case it's a
div
I need to check with the frontend developers about the value change logic
g
I would provide an example exactly like the one you need
p
I will try to provide the code snippet on Monday .. but what I can see while inspecting the element the main component is a
div
and I have a
button
which we need to drag to the right
I tried long press and
moveright
etc and it didn't help