Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Actions class from Selenium.
Selenium Python
from selenium.webdriver.common.[1] import ActionChains
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect module names like 'actions' or 'common.action_chains'.
✗ Incorrect
The correct import path for ActionChains is selenium.webdriver.common.action_chains.
2fill in blank
mediumComplete the code to create an ActionChains object for the driver.
Selenium Python
actions = ActionChains([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are not the WebDriver instance.
✗ Incorrect
The ActionChains object needs the WebDriver instance, which is usually named driver.
3fill in blank
hardFix the error in the code to perform a click and hold action on an element.
Selenium Python
actions.click_and_hold([1]).perform() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the driver or browser instead of the element.
✗ Incorrect
The click_and_hold method requires a WebElement, not the driver or browser.
4fill in blank
hardFill both blanks to move to an element and release the mouse button.
Selenium Python
actions.move_to_element([1]).[2]().perform()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click' instead of 'release' for the second blank.
✗ Incorrect
You move to the target element and then release the mouse button to complete the action.
5fill in blank
hardFill all three blanks to drag an element and drop it on another element.
Selenium Python
actions.[1]([2], [3]).perform()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'click_and_hold' instead of 'drag_and_drop'.
✗ Incorrect
The drag_and_drop method takes the source and target elements as arguments.