Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an Actions object for complex gestures.
Selenium Java
WebDriver driver = new ChromeDriver();
Actions actions = new [1](driver); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Action' instead of 'Actions' causes a compilation error.
Using 'Robot' is unrelated to Selenium's Actions API.
✗ Incorrect
The Actions class is used to build complex user gestures in Selenium WebDriver.
2fill in blank
mediumComplete the code to perform a double click using Actions API.
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() performs a single click, not double.
Using contextClick() performs a right-click.
✗ Incorrect
The doubleClick() method performs a double click on the specified element.
3fill in blank
hardFix the error in the code to drag and drop an element using Actions API.
Selenium Java
Actions actions = new Actions(driver);
actions.dragAndDrop(source, [1]).perform(); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'driver' instead of an element causes a compile-time error.
Using 'element' or 'destination' may not match the variable name.
✗ Incorrect
The dragAndDrop() method requires source and target elements; 'target' is the correct parameter name.
4fill in blank
hardFill both blanks to build and perform a click-and-hold followed by release on an element.
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 clickAndHold() does not hold the mouse button.
Omitting release() causes the mouse button to stay pressed.
✗ Incorrect
clickAndHold() presses mouse button down; release() releases it, completing the gesture.
5fill in blank
hardFill all three blanks to build a sequence: move to element, click, then send keys.
Selenium Java
Actions actions = new Actions(driver); actions.[1](element).[2]().sendKeys([3]).perform();
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using doubleClick() instead of click() changes the gesture.
Not quoting the string in sendKeys causes syntax errors.
✗ Incorrect
moveToElement() moves mouse, click() clicks, sendKeys("Hello") types text.