2

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?

asked Jun 23, 2014 at 10:10
5
  • Do you really need to slide it, or do you just need to set it? Commented Jun 23, 2014 at 12:17
  • Actually I want to set it by sliding. Is there any way of doing this? If not then how can we set the values. I will try that if that could be enough. Commented Jun 23, 2014 at 12:21
  • Since there isn't a native HTML slider, it may help for you to specify how the slider is implemented, e.g. does the page use the jQuery slider? Commented Jun 23, 2014 at 12:25
  • yup it's a jQuery slider. Commented Jun 23, 2014 at 12:40
  • 1
    If you don't have the ID, you will need to use some other kind of locator (e.g. CSS or XPath) to identify the div. Regarding setting the value, a Google search for "selenium jquery slider" turned up several suggestions. See this for example. Commented Jun 23, 2014 at 12:49

1 Answer 1

4

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.

answered Jun 23, 2014 at 18:32
1
  • I will try out your ideas. @Niels. Commented Jun 24, 2014 at 5:29

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.