Bird
0
0

You want to verify that a drag and drop action changed the CSS background color of the target element to green. Which assertion is best to check this in Selenium Java?

hard📝 Application Q9 of 15
Selenium Java - Actions Class
You want to verify that a drag and drop action changed the CSS background color of the target element to green. Which assertion is best to check this in Selenium Java?
AassertTrue(target.getText().contains("green"));
BassertFalse(target.isDisplayed());
CassertNotNull(target.getAttribute("style"));
DassertEquals("rgba(0, 128, 0, 1)", target.getCssValue("background-color"));
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct CSS property check

    To verify background color, getCssValue("background-color") returns the color in rgba format.
  2. Step 2: Evaluate assertion options

    assertEquals("rgba(0, 128, 0, 1)", target.getCssValue("background-color")); compares expected rgba green value exactly. Others check unrelated properties or visibility.
  3. Final Answer:

    assertEquals("rgba(0, 128, 0, 1)", target.getCssValue("background-color")); -> Option D
  4. Quick Check:

    Use getCssValue and assertEquals for style checks [OK]
Quick Trick: Check CSS with getCssValue and assertEquals [OK]
Common Mistakes:
  • Checking text instead of CSS color
  • Using isDisplayed for style verification
  • Not comparing exact CSS value format

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes