Can't select price range (Selenium + Python)


  • QA Engineer

    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()
    driver.get("http://practice.automationtesting.in/shop/")
    driver.maximize_window()
    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:

    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()
    


Suggested Topics

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