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 el = driver.findElement(By.cssSelector(".btn"));
actions.contextClick(el).perform();
What is the expected behavior?
ANo action performed
BRight-click on the element with class 'btn'
CPerforms double-click on the element
DThrows IllegalArgumentException
Step-by-Step Solution
Solution:
  1. Step 1: Understand contextClick with element parameter

    The contextClick(WebElement) method performs a right-click directly on the given element.
  2. Step 2: Confirm expected behavior

    The code right-clicks on the element with class 'btn' and executes the action with perform().
  3. Final Answer:

    Right-click on the element with class 'btn' -> Option B
  4. Quick Check:

    contextClick(element) = right-click on element [OK]
Quick Trick: contextClick(element) right-clicks directly on element [OK]
Common Mistakes:
  • Confusing contextClick(element) with double-click
  • Expecting exceptions without cause
  • Forgetting to call perform()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes