11. Mouse Gestures & Keyboard Actions with ActionChains

ActionChains in Python

from selenium.webdriver.common.action_chains import ActionChains

actions = ActionChains(driver)

# Hover to reveal menu:
menu = driver.find_element(By.ID, "nav-menu")
actions.move_to_element(menu).perform()

# Drag and drop:
source = driver.find_element(By.ID, "draggable")
target = driver.find_element(By.ID, "droppable")
actions.drag_and_drop(source, target).perform()

Task

  • Implement build_action_log:
  • 1. Accept action_name string.
  • 2. Return f"EXECUTED: {action_name}".
💡Common doubts
Did you like the problem?
Lesson 11 of 16
Python
Loading code editor…
Next