Selenium Python- Drag and Drop Using Action Chains

25 views Asked by At

Drag_and drop

action_chain = ActionChains(driver)
    
     for index in range(1, 12):
        source_element = driver.find_element(By.XPATH, "//*[@id='sortable']/li[12]")
         target_element = driver.find_element(By.XPATH, f"//*[@id='sortable']/li[{index}]")
         WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, f"//*[@id='sortable']/li[{index}]")))
         action_chain.click_and_hold(source_element).move_to_element(target_element).release().perform()
         time.sleep(7)
    
     sortable_elements = WebDriverWait(driver, 10).until(
         EC.presence_of_all_elements_located((By.XPATH, "//*[@id='sortable']/li")))
     new_order = [element.text for element in sortable_elements]
     assert initial_order != new_order 

Above is my code and My question is when performing the actions it is working but when the elements [12,4] [12,8]. elements are returning to their original positions after performing the drag-and-drop operations,

solution for my question I have tried all actions chains options

0

There are 0 answers