Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to perform a mouse hover on the element.
Selenium Java
Actions actions = new Actions(driver);
actions.[1](element).perform(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of moveToElement() causes a click instead of hover.
Forgetting to call perform() after moveToElement().
✗ Incorrect
The moveToElement() method moves the mouse to the middle of the specified element, which is how you perform a mouse hover.
2fill in blank
mediumComplete the code to hover over the element and then click a sub-menu item.
Selenium Java
Actions actions = new Actions(driver);
actions.moveToElement(menu).[1](submenu).click().perform(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using click() instead of moveToElement() before clicking submenu.
Not chaining moveToElement calls properly.
✗ Incorrect
You need to move the mouse to the submenu element after hovering the menu, so moveToElement(submenu) is correct.
3fill in blank
hardFix the error in the code to correctly hover over the element.
Selenium Java
Actions actions = new Actions(driver);
actions.moveToElement([1]).perform(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing driver instead of element causes a compile-time error.
Passing class names or types instead of an instance.
✗ Incorrect
moveToElement() requires a WebElement to hover over, so 'element' is the correct argument.
4fill in blank
hardFill both blanks to create an Actions chain that hovers over an element and then clicks it.
Selenium Java
Actions actions = new Actions(driver); actions.[1](element).[2]().perform();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using sendKeys() instead of click() causes wrong action.
Calling perform() before click() ends the chain prematurely.
✗ Incorrect
First move the mouse to the element, then click it, and finally perform the action chain.
5fill in blank
hardFill all three blanks to hover over an element, pause for 2 seconds, then click it.
Selenium Java
Actions actions = new Actions(driver); actions.[1](element).pause([2]).[3]().perform();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pause(2) instead of pause(2000) causes no wait.
Using doubleClick() instead of click() changes the action.
✗ Incorrect
moveToElement() hovers, pause(2000) waits 2 seconds, then click() clicks the element.