Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an Actions object for double click.
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 doubleClick()
Using contextClick() which is right-click
Forgetting to call perform()
✗ Incorrect
The doubleClick() method in Actions class performs a double click on the given element.
2fill in blank
mediumComplete the code to import the Actions class.
Selenium Java
import org.openqa.selenium.[1].Actions;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing from webdriver package
Importing from support package
✗ Incorrect
The Actions class is in the org.openqa.selenium.interactions package.
3fill in blank
hardFix the error in the code to perform a double click on the element.
Selenium Java
Actions actions = new Actions(driver);
actions.doubleClick([1]).perform(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing driver instead of element
Passing null causing NullPointerException
✗ Incorrect
The doubleClick() method requires a WebElement to act on, which is 'element' here.
4fill in blank
hardFill both blanks to move to the element and then double click 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 click() instead of doubleClick()
Not moving to the element before doubleClick()
✗ Incorrect
First move to the element, then perform doubleClick() before calling perform().
5fill in blank
hardFill all three blanks to create an Actions object, move to the element, and double click it.
Selenium Java
Actions [1] = new Actions(driver); [2].moveToElement(element).[3]().perform();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently
Using click() instead of doubleClick()
✗ Incorrect
Create 'actions' object, then use it to move to element and doubleClick.