Search code examples
javascriptangularjsautomationprotractorsliders

What is the proper way to set values to a Slider Input? (Protractor Automation)


I have this slider input in html code:

enter image description here

enter image description here

(Sorry about this being an image, I do not have access to the code for the page, I just have to test it).

And I'm trying this code:

this.maxdivedepth = function (value) {
    var slider = util.getElementAsyncSafe(by.id("maximum-dive-depth"));
    browser.actions().dragAndDrop(
            slider,
            {x: value, y: 0}
    ).mouseUp().perform();
};

'value' being "100" for example.

Terminal doesn't show any error, but I don't see the sliders doing anything..

I tried several things, using diferent selectors for example, but still the same.

Can anybody help me with this?


Solution

  • First you need to identify the locator for the circle element displayed on the slider. Then you can drag it using below code,

    var slider = $(".rz-pointer-min"); //im not sure about the locator of the circle element.
    browser.actions().mouseMove(slider).mouseDown().mouseMove({x:20,y:0 }).mouseUp().perform()