Has anyone an idea how to test a ng5-slider (e.g. changing the value) with cypress. I tried the suggestions from the documentation(like using trigger) but I couldn't make it work.
You can try with type('{rightarrow} {rightarrow}')
to move the slider towards right and test for the new value obtained. The below sample test that I have tried in ng5-slider
sample site and it works fine. Identify the slider and move with type()
method. The default slider value is 100
and after moving the slider the changed value is `103'
describe('Try an Ng Slider test ', function () {
it('Check the slider and test the new slider value', function () {
cy.visit('https://angular-slider.github.io/ng5-slider/')
cy.get('a:contains("Go to demo")').parents('.mt-4').find('a').contains("Go to demo").click()
cy.wait(1000)
cy.get('#simple-slider').find('ng5-slider').find('span[aria-valuetext="100"]').type('{rightarrow}{rightarrow}{rightarrow}')
cy.get('#simple-slider').find('ng5-slider').find('span[aria-valuemax="250"]').invoke('attr', 'aria-valuetext', "103")
.should('have.attr', 'aria-valuetext', '103')
cy.scrollTo('top');
})
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With