I have a small test case:

I tried to use ActionChains, but no result.

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome()
slider = driver.find_element_by_xpath("//*[@id='woocommerce_price_filter-2']/form/div/div[1]/span[2]")
move = ActionChains(driver)
move.click_and_hold(slider).move_by_offset(10, 0).release().perform()

Can someone explain, what I'm doing wrong? Thanks.

  • It seems you can find the slider simply by using class name (ui-slider-handle). What is the result when you run your code? – João Farias Jul 22 '19 at 19:33
  • João Farias, when I use class_name("ui-slider-handle"), only the firs selector is moved. So I verified using "assert" if my slider (by xpath) is visible, and I received no error. Then I changed the last line of code: move.click_and_hold(slider).move_by_offset(-28, 0).release().perform() And I selected from range 150 to 451. Unfortunately, I can't select exactly to 450. – rodut Jul 23 '19 at 5:48
  • João Farias, thank you for your time. – rodut Jul 23 '19 at 5:56

It seems you can find the slider simply by using class name:

enter image description here

sliders = driver.find_elements_by_class_name("ui-slider-handle") #Selecting all sliders
left_slider = sliders[0]
right_slider = sliders[1]
move = ActionChains(driver)
# Moving the left slider
move.click_and_hold(left_slider).move_by_offset(10, 0).release().perform()
# Moving the right slider
move.click_and_hold(right_slider).move_by_offset(-28, 0).release().perform()
| improve this answer | |
  • It's working just fine. Thank you. – rodut Jul 23 '19 at 6:49
  • Most welcome rodut. Could you mark the answer as accepted? It really motivates contributors. – João Farias Jul 23 '19 at 6:56
  • Yes, sure. Thank you. – rodut Jul 23 '19 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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