DEV Community

ABUL HASAN A
ABUL HASAN A

Posted on

task 11

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
import time

Start a new browser session

driver = webdriver.Chrome()

try:
# Open the URL
driver.get("https://jqueryui.com/droppable/")

# Switch to the iframe containing the draggable elements
iframe = driver.find_element(By.CLASS_NAME, "demo-frame")
driver.switch_to.frame(iframe)

# Locate the draggable element
draggable_element = driver.find_element(By.ID, "draggable")

# Locate the droppable element
droppable_element = driver.find_element(By.ID, "droppable")

# Perform the drag and drop operation
actions = ActionChains(driver)
actions.drag_and_drop(draggable_element, droppable_element).perform()

# Wait for a few seconds to see the result
time.sleep(2)
Enter fullscreen mode Exit fullscreen mode

finally:
# Close the browser
driver.quit()

Image description

Top comments (0)