Python / WebDriver / Drag & Drop
Few times I was asked which code should be implemented in a test if user interface using drag&drop functionality. Please see how that works.
[code language="python"]
from selenium import webdriver
# see below, this is what are you looking for.
from selenium.webdriver.common.action_chains import ActionChains
moved = selenium_driver.find_element(By.XPATH, <xPath here>)
target = selenium_driver.find_element(By.CSS_SELECTOR, <css here>)
ActionChains(selenium_driver).drag_and_drop(moved, target).perform()
[/code]
[code language="python"]
from selenium import webdriver
# see below, this is what are you looking for.
from selenium.webdriver.common.action_chains import ActionChains
moved = selenium_driver.find_element(By.XPATH, <xPath here>)
target = selenium_driver.find_element(By.CSS_SELECTOR, <css here>)
ActionChains(selenium_driver).drag_and_drop(moved, target).perform()
[/code]
Comments
Post a Comment