Forum Discussion

pkudrys's avatar
pkudrys
Contributor
4 months ago

Set web slider position without dragging slider

Hi guys, 

Is there a way to set the web slider position, without the need to drag the slider (or using cursor/page up/down keys)? I found SetPosition action or wPosition property, but neither seem work with the web objects.

And yes, I also tried set "Keys" or "value", but these does not work either. 

Thanks for any idea :) 

PS: 

I ended-up with below solution, using Keys action. 

      else if (inputElement.ObjectType == "Slider")
      {
        inputElement.Keys("[Home]");
        for (let i = 0; i < (csvInputValue/10); i++)
        {
          inputElement.Keys("[Right]"); 
        }
      }

Basically, it Home key sets the slider to zero position and then Right key in loop sets the slider to expected position. 

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    What properties and methods are exposed, when using Object Spy tool?

    • pkudrys's avatar
      pkudrys
      Contributor

      Hi, sorry for a delayed reply. I was on a vacation. here is the list of available methods

       

  • nastester's avatar
    nastester
    Regular Contributor

    I had a similar issue and I subsequently moved on from it.  I have a horizontal slider than can be dragged to expand a panel.  I noticed using the Object Spy that the Left and ScreenLeft property would change when it was dragged.  I was hoping to find a way to manipulate these properties with a script or something but never figured it out.  Maybe something similar can be used in your case 

    • pkudrys's avatar
      pkudrys
      Contributor

      Thanks for the suggestion. In the end, I ended up with using Keys. basically, I first set the slider to 0 position, using Home key, and then using Right key to precisely set the slider position to given value. 

  • JDR2500's avatar
    JDR2500
    Frequent Contributor

    Any chance MouseWheel works if you hover over the slider?  In my experience it works for some sliders but not all of them. 

    If that doesn't work maybe as suggested there is some other native method buried in the Object Spy list. 

    • pkudrys's avatar
      pkudrys
      Contributor

      Hi, thanks for the suggestion. Sadly, mouse wheel does not work when the mouse is hovering above the slider. But it may eventually work form code, because there is a MouseWheel method available.  

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        Code example, on changing the value property of a slider control.

        function Slider()
        {
            // https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_rangeslider
            
            var page = NameMapping.Sys.browser.Page("https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_rangeslider");
            var slider = page.Panel("container").Panel("iframecontainer").Panel("iframe").Panel("iframewrapper").Frame("iframeResult").Panel(0).Slider("myRange");
            slider.value = 21;
        }