Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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?

share|improve this question
Do you really need to slide it, or do you just need to set it? –  user246 Jun 23 '14 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. –  Ashwani Raj Jun 23 '14 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? –  user246 Jun 23 '14 at 12:25
yup it's a jQuery slider. –  Ashwani Raj Jun 23 '14 at 12:40
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. –  user246 Jun 23 '14 at 12:49

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
I will try out your ideas. @Niels. –  Ashwani Raj Jun 24 '14 at 5:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.