Skip to content
CodeKruPro

Verify an element's colour (Java)

QuizMediumJava onlyAsked in: Accenture, Infosys

A span is styled color: red. In Chrome, what does span.getCssValue("color") return, and how do you compare it with #ff0000?

  • rgba(255, 0, 0, 1); convert with Color.fromString(value).asHex() and compare with #ff0000
  • red, exactly as written in the style
  • #ff0000 directly
  • It throws, because colours need JavaScript

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in