webdriver icon indicating copy to clipboard operation
webdriver copied to clipboard

Inconsistent RGB vs RGBA return value

Open vmassol opened this issue 6 years ago • 5 comments

Guys, I'm getting the following in my selenium test:

expected: <rgb(255, 0, 0)> but was: <rgba(255, 0, 0, 1)>

The issue is that I get different result when our tests is executed on our CI or locally. In both cases our app is running in a docker container and the browser and selenium "proxy" is also running in a docker container so that should be the same. What is different is the test itself (ie the selenium client side): locally it's running directly on the OS (macosx for me) and on the CI it's running inside a docker container (debian).

Locally I get rgb(255, 0, 0) and in the CI we get rgba(255, 0, 0, 1).

Note: we use WebElement#getCSSValue() to return the value.

Any idea? Thanks

vmassol avatar Oct 04 '19 06:10 vmassol

Which versions of Firefox are you running locally and in the CI? Do you have an HTML test case that reproduces the problem?

I can’t recall we’ve changed anything in this area recently, but I will need more information to diagnose this properly.

andreastt avatar Oct 07 '19 11:10 andreastt

Sorry, in my last comment I made the assumption this was a geckodriver bug. If there’s behaviour in a particular driver that is buggy, please report a bug with the driver. This repo covers the specification text only.

andreastt avatar Oct 07 '19 11:10 andreastt

Can we re-open this issue. The inconsistency still applies between Chromedriver (returning an rgba value) and Geckodriver (returning an rgb value). Also it would be nice to find a common formatting to avoid e.g. "rgb(0,0,0)" vs "rgb(0, 0, 0)". The CSSOM specification may not prioritize these aspects, but the WebDriver should, given its crucial role in testing which requires consistent values across browser.

Interestingly getComputedStyle(document.body).borderColor returns an rgb value in both browser, so would it be possible to just defer to that?

cc @AutomatedTester @whimboo @sadym-chromium

christian-bromann avatar Mar 13 '24 17:03 christian-bromann

I raised a PR in wpt.fyi with a test for this: https://github.com/web-platform-tests/wpt/pull/45088

christian-bromann avatar Mar 13 '24 17:03 christian-bromann

Interestingly getComputedStyle(document.body).borderColor returns an rgb value in both browsers, so would it be possible to just defer to that?

Alternatively, for CSS <color> values specifically, we could say that the return value must be serialized according to https://drafts.csswg.org/css-color-4/#serializing-color-values.

mathiasbynens avatar Mar 14 '24 08:03 mathiasbynens