Skip to content

Add tested Color examples for the Colors page - #2997

Open
vishalchincholi1 wants to merge 6 commits into
SeleniumHQ:trunkfrom
vishalchincholi1:docs/colors-tested-examples
Open

vishalchincholi1 wants to merge 6 commits into
SeleniumHQ:trunkfrom
vishalchincholi1:docs/colors-tested-examples

Conversation

@vishalchincholi1

Copy link
Copy Markdown

Description

Converts the Colors page (webdriver/support_features/colors) from inline snippets to gh-codeblock references backed by runnable tests, in the en, ja, pt-br and zh-cn copies.

  • Java: fills the empty ColorsTest.java.
  • Python: adds tests/support/test_colors.py.
  • Ruby: fills the empty color_spec.rb.
  • Kotlin: adds support/ColorsTest.kt.

The tests cover creating colors from hex, rgb, rgb percent, rgba, rgba percent, hsl and hsla strings, named colors and transparent, then reading an element's color and background-color from colorPage.html and comparing and converting them with hex, rgb and rgba.

Two notes for review:

  • The Ruby Color class has no named-color or transparent support (checked in selenium-webdriver 4.52.0). Those two Ruby tabs now show the implementation-missing badge instead of a snippet that would raise an error.
  • The old element snippets used a login element that no test page has. They now use the namedColor element on colorPage.html.

Motivation and Context

Part of #2890 (the Colors page, as claimed in this comment). Every snippet on the page was untested and marked with badge-examples.

Testing

  • Python: pytest tests/support/test_colors.py, 4 passed.
  • Java: mvn test -Dtest=ColorsTest, 4 passed.
  • Kotlin: mvn test -Dtest=ColorsTest, 4 passed.
  • Hugo build: no errors.
  • Ruby: not run locally, because the native gems would not build on my Windows machine. It relies on CI.
  • The gh-codeblock line ranges were checked against the final files with a script, since Hugo needs a GitHub token to fetch the snippets locally.

Types of changes

  • Change to the site (I have double-checked the Netlify deployment, and my changes look good)
  • Code example added (and I also added the example to all translated languages)
  • Improved translation
  • Added new translation (and I also added a notice to each document missing translation)

Checklist

  • I have read the contributing document.
  • I have used hugo to render the site/docs locally and I am sure it works.

I have signed the CLA.

Replace the inline snippets on the Colors page with gh-codeblock
references to runnable tests, in the en, ja, pt-br and zh-cn copies.

- Java: fill the empty ColorsTest.
- Python: add tests/support/test_colors.py.
- Ruby: fill the empty color_spec.rb.
- Kotlin: add support/ColorsTest.kt.

The tests cover hex, rgb, rgb percent, rgba, rgba percent, hsl and
hsla strings, named colours, transparent, and reading an element's
color and background-color from the colorPage.html test page, then
comparing and converting with hex, rgb and rgba.

The Ruby Color class has no named-colour or transparent support
(checked in selenium-webdriver 4.52.0), so those two Ruby tabs now
show the implementation-missing badge instead of a snippet that
would raise an error. The Ruby element test builds expected colours
from rgb strings for the same reason.

The element snippets now use the namedColor element on colorPage.html
instead of a "login" element that no test page provides.

Verified locally: Python (4 passed), Java (4 passed), Kotlin (4
passed), Hugo build (no errors). Not run locally: Ruby rspec and
rubocop, because the native gems could not be built on this machine.
Ruby relies on CI. Hugo cannot resolve gh-codeblock snippets without
a GitHub token, so line ranges were checked with a script instead.

Part of SeleniumHQ#2890
@netlify

netlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

👷 Deploy request for selenium-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 73a957c

@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@rpallavisharma

Copy link
Copy Markdown
Member

@vishalchincholi1 , ruby tests are failing. Can you have a look at the failure.
Also a feedback please generate small PRs. one per language. and with example code, for the language update the gh code block for it across all files.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants