Bird
0
0

Identify the error in this Selenium Java code snippet for a drag-and-drop action:

medium📝 Debug Q14 of 15
Selenium Java - Actions Class
Identify the error in this Selenium Java code snippet for a drag-and-drop action:
Actions action = new Actions(driver);
action.dragAndDrop(source, target);
AThe perform() method is missing.
BThe perform() method is called on the wrong object.
CThe dragAndDrop method must be followed by perform() in the same statement.
DThe dragAndDrop method does not exist in Actions API.
Step-by-Step Solution
Solution:
  1. Step 1: Understand method chaining in Actions API

    Actions methods like dragAndDrop add actions to a sequence that must be executed with perform().
  2. Step 2: Check how perform() is called

    perform() is missing, so the drag-and-drop will not execute. Correct usage: action.dragAndDrop(source, target).perform();
  3. Final Answer:

    The perform() method is missing. -> Option A
  4. Quick Check:

    dragAndDrop needs perform() [OK]
Quick Trick: dragAndDrop needs perform() [OK]
Common Mistakes:
  • Forgetting to call perform() after dragAndDrop
  • Assuming dragAndDrop executes immediately
  • Confusing method existence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes