title: How to get element color with Selenium
body: <p>I want to check the color of an element in an html page. 
  The color of this element is set with a javascript, look at the image <a href="https://i.stack.imgur.com/KbQOB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KbQOB.png" alt="enter image description here"></a></p>
  
  <p>The element with div-id "Ab_banco_M1T1_switch" can assume 4 values, of course only one of them is displayed according to the value of "val" variable. 
  The val variable is set from the server somehow, it seemes the script polls the server every X-seconds and update the value of val. </p>
  
  <p>I've tried to get the color of the element as follow: </p>
  
  <pre><code>WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Ab_banco_M1T1_switch")));
  
  element.getAttribute("background")
  element.getAttribute("style")
  element.getAttribute("background-color") 
  element.getCssValue("style")
  element.getCssValue("color")
  </code></pre>
  
  <p>with no success, they return "null" or the backgorund-color of the page.</p>
  
  <p>The only way to get the color is to use the Xpath
      <code>/html/body/div/div[2]/div[2]/div[2]/div/div/div/div[3]/div (for red, if I want the green 
     /html/body/div/div[2]/div[2]/div[2]/div/div/div/div[2]/div)</code></p>
  
  <p>But it is not what I want. Indeed, the Xpath localizes the element, but it doesn't tell me if the color displayed is red or another one, I can know it only by looking at the web page. </p>
  
  <p>In other words, I would like to access the  current displayed color as Firebug does, look at the panel on right side, you can see that <code>element.style -&gt;background-Color = red</code>. </p>
  
  <p>When I invoke element,<code>getCssCValue("background-color")</code> I get the backgorund-color of <code>#body_right_div</code>. </p>
  
  <p>Thank you in advance. </p>