How to automate range values using web driver?



  • I have to test a price range bar implemented with a jQuery slider. Suppose the defined range is 100-10,000. I want web driver to slide the minimum value to 2000 and Maximum value to 8000. I thought of using dragAndDrop property but got stuck in the situation to give target value. I am in a situation where I don't have id's for both the div.

    What to do?



  • The actual slider is a link-element you should be able to define a css selector based on its classes.

    <a class="ui-slider-handle ui-state-default ui-corner-all" href="//#"></a>
    

    The first you find is the left slider, the second the right slider.

    I have successfully used use the Action Builder and the MoveToOffsetAction to drag a slider X number of pixels into a direction. I would only do this if you need to verify an event fired during the sliding.

    The min max part of the slider is part of the jQuery framework, also updating the range. I really wonder if you want to test the frameworks behaviour. I would just set the value of the slider to the desired ranged value with the JavaScriptExecuter by using the range setter of the jQuery slider.

    I think its a jQuery best practise to put the slider component in to a div with an id. If your slider does not have an id, urge the developers to give it one. Note the draggers have no id and can only be found in the slider compontent div on its class.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2