w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
681 stars 195 forks source link

Inconsistent RGB vs RGBA return value #1447

Open vmassol opened 5 years ago

vmassol commented 5 years ago

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

andreastt commented 5 years ago

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 commented 5 years ago

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.

christian-bromann commented 8 months ago

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 commented 8 months ago

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

mathiasbynens commented 8 months ago

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.