Bird
0
0

Consider this code:

medium📝 Predict Output Q5 of 15
Selenium Java - Actions Class
Consider this code:
Actions actions = new Actions(driver);
WebElement source = driver.findElement(By.cssSelector(".item"));
WebElement target = driver.findElement(By.cssSelector(".box"));
actions.clickAndHold(source).moveToElement(target).release().perform();
boolean displayed = target.isDisplayed();
System.out.println(displayed);

What will be the output if the drag and drop is visually successful and the target element remains visible?
Anull
Btrue
Cfalse
DAn exception is thrown
Step-by-Step Solution
Solution:
  1. Step 1: Understand the drag and drop steps

    The code clicks and holds the source, moves to target, releases, then performs the action.
  2. Step 2: Check target visibility

    Since the target remains visible, target.isDisplayed() returns true, which is printed.
  3. Final Answer:

    true -> Option B
  4. Quick Check:

    target.isDisplayed() after drag = true if visible [OK]
Quick Trick: Use isDisplayed() to check element visibility after actions [OK]
Common Mistakes:
  • Assuming isDisplayed() returns false after drag
  • Confusing clickAndHold with dragAndDrop method
  • Forgetting to call perform()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes