WebElement#getCssValue does not return rgba value in case of hexa color
See original GitHub issue🐛 Bug Report
When using WebElement#getCssValue
the returned value is not necessarily a rgba value when the requested color is in fact an hexadecimal value, contrarily to what’s explained in the WebElement javadoc:
https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/WebElement.java#L246-L265
Now I’ve not been able to track down in the W3C WebDriver specification if the color values should be systematically rgba or not, so maybe it’s just a javadoc issue.
To Reproduce
Detailed steps to reproduce the behavior: Request the CSS color value of an element containing an hexadecimal color.
Expected behavior
The color is returned as an RGBA value.
Test script or set of commands reproducing this issue
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
// The "connection" button, cf the following gif
WebElement element = driver.findElement(By.id("gb_70"));
// expected to be RGBA according to the javadoc
String color = element.getCssValue("border-top-color");
System.out.println("Color CSS value: " + color);
driver.quit();
Environment
OS: Linux Browser: Firefox Browser version: 69.0.3 Browser Driver version: GeckoDriver 0.25.0 Language Bindings version: Java 3.141.59
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Thank you for providing the details again. Apologies from my end. I misunderstood the issue here. Appreciate the clarification comment. It seems the values returned are dependent on the browser interpretation and implementation. I have updated the Javadoc appropriately.
So apparently my issue description was not clear enough, but you show exactly the issue I had: I was expecting this method to always return RGBA and not RGBA or RGB. You can check the associated commit on our project, I had to change some test expectation from rgba value to rgb because of it: https://github.com/xwiki/xwiki-platform/commit/f6366253740a905147f21a7e43d901e7bce36f61
Now IMO the fix is just to clarify the javadoc to express that the value can be either rgba or rgb, since right now it says:
[EDIT: note that I created it as a bug since apparently this commit was related with an upgrade of selenium, so I wasn’t sure if it was a regression or not]