Bird
0
0

You want to drag an element and drop it at an offset of 50 pixels right and 20 pixels down from its current position. Which Actions method chain correctly performs this?

hard📝 Application Q8 of 15
Selenium Java - Actions Class
You want to drag an element and drop it at an offset of 50 pixels right and 20 pixels down from its current position. Which Actions method chain correctly performs this?
Aactions.clickAndHold(source).moveByOffset(50, 20).release().perform();
Bactions.dragAndDrop(source, target).moveByOffset(50, 20).perform();
Cactions.moveToElement(source).dragAndDropBy(50, 20).release().perform();
Dactions.click(source).moveByOffset(50, 20).release().perform();
Step-by-Step Solution
Solution:
  1. Step 1: Understand moveByOffset usage

    moveByOffset(x,y) moves the mouse pointer by given pixels from current position.
  2. Step 2: Analyze each option

    actions.clickAndHold(source).moveByOffset(50, 20).release().perform(); correctly clicks and holds source, moves by offset, releases, and performs. Others misuse methods or order.
  3. Final Answer:

    actions.clickAndHold(source).moveByOffset(50, 20).release().perform(); -> Option A
  4. Quick Check:

    Use clickAndHold + moveByOffset + release + perform for offset drag [OK]
Quick Trick: Use moveByOffset for pixel-based drag and drop [OK]
Common Mistakes:
  • Using dragAndDrop with moveByOffset incorrectly
  • Calling release before moveByOffset
  • Using click instead of clickAndHold

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes