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]

Comments

Popular posts from this blog

Robot Framework vs Cucumber

Performance Testing of RESTful APIs Using JMeter

Verification displayed number of rows inside table by Robot Framework