This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Contributing to the Selenium site & documentation

Information on improving documentation and code examples for Selenium

Selenium is a big software project, its site and documentation are key to understanding how things work and learning effective ways to exploit its potential.

This project contains both Selenium’s site and documentation. This is an ongoing effort (not targeted at any specific release) to provide updated information on how to use Selenium effectively, how to get involved and how to contribute to Selenium.

Contributions toward the site and docs follow the process described in the below section about contributions.


The Selenium project welcomes contributions from everyone. There are a number of ways you can help:

Report an issue

When reporting a new issues or commenting on existing issues please make sure discussions are related to concrete technical issues with the Selenium software, its site and/or documentation.

All of the Selenium components change quite fast over time, so this might cause the documentation to be out of date. If you find this to be the case, as mentioned, don’t hesitate to create an issue for that. It also might be possible that you know how to bring up to date the documentation, so please send us a pull request with the related changes.

If you are not sure about what you have found is an issue or not, please ask through the communication channels described at https://selenium.dev/support.

What to Help With

This repository holds both the Selenium site and its documentation. Read the guide for the area you want to change:

  • Selenium site: the home page, downloads, projects, blog, and other pages outside of the documentation.
  • Documentation: the pages under /documentation, their structure, and their translations.
  • Code examples: creating runnable code examples and rendering them in the documentation.

Contribution Mechanics

The Selenium project welcomes new contributors. Individuals making significant and valuable contributions over time are made Committers and given commit-access to the project.

This guide will guide you through the contribution process.

Step 1: Fork

Fork the project on GitHub and check out your copy locally.

% git clone git@github.com:seleniumhq/seleniumhq.github.io.git
% cd seleniumhq.github.io

Dependencies: Hugo

We use Hugo and the Docsy theme to build and render the site. You will need the “extended” Sass/SCSS version of the Hugo binary to work on this site. We recommend to use Hugo 0.167.0 .

Please follow the Install Hugo instructions from Docsy.

Dependencies: Go

The Docsy theme is pulled in as a Hugo Module, so Hugo needs Go to resolve it when you run hugo server. Install any version satisfying the minimum in go.mod.

Dependencies: Node.js (optional, for the production CSS pipeline)

Node.js is not required to preview the site with hugo server — in development mode Docsy skips PostCSS. You only need Node.js (any current release) if you want your local build to match the production CSS pipeline (autoprefixer/PostCSS), as run by hugo --minify in build-site.sh. In that case, run npm install in website_and_docs first.

Note: This may change with a future Hugo/Docsy upgrade. If theme assets (e.g. Bootstrap/Font Awesome) move from Hugo Modules to npm packages, npm install — and therefore Node.js — could become required for all builds, not just the production pipeline.

Step 2: Branch

Create a feature branch and start hacking:

% git checkout -b my-feature-branch

We practice HEAD-based development, which means all changes are applied directly on top of dev.

Step 3: Make changes

The repository contains the site and docs. To make changes to the site, work on the website_and_docs directory. To see a live preview of your changes, run hugo server on the site’s root directory.

% cd website_and_docs
% hugo server

The project loads code from GitHub, if that code has been updated, and it isn’t reflected in your preview, you can run hugo without the cache: hugo server --ignoreCache

See Style Guide for more information on our conventions for contribution, and the guides listed in What to Help With for the area you are changing.

Step 4: Commit

First make sure git knows your name and email address:

% git config --global user.name 'Santa Claus'
% git config --global user.email 'santa@example.com'

Writing good commit messages is important. A commit message should describe what changed, why, and reference issues fixed (if any). Follow these guidelines when writing one:

  1. The first line should be around 50 characters or less and contain a short description of the change.
  2. Keep the second line blank.
  3. Wrap all other lines at 72 columns.
  4. Include Fixes #N, where N is the issue number the commit fixes, if any.

A good commit message can look like this:

explain commit normatively in one line

Body of commit message is a few lines of text, explaining things
in more detail, possibly giving some background about the issue
being fixed, etc.

The body of the commit message can be several paragraphs, and
please do proper word-wrap and keep columns shorter than about
72 characters or so. That way `git log` will show things
nicely even when it is indented.

Fixes #141

The first line must be meaningful as it’s what people see when they run git shortlog or git log --oneline.

Step 5: Rebase

Use git rebase (not git merge) to sync your work from time to time.

% git fetch origin
% git rebase origin/trunk

Step 6: Test

Always remember to run the local server, with this you can be sure that your changes have not broken anything.

Step 7: Push

% git push origin my-feature-branch

Go to https://github.com/yourusername/seleniumhq.github.io.git and press the Pull Request and fill out the form. Please indicate that you’ve signed the CLA. To sign the CLA, visit cla-assistant.io/SeleniumHQ/seleniumhq.github.io and click the “Sign in with GitHub to agree” button on the page.

Pull requests are usually reviewed within a few days. If there are comments to address, apply your changes in new commits (preferably fixups) and push to the same branch.

Step 8: Integration

When code review is complete, a committer will take your PR and integrate it on the repository’s trunk branch. Because we like to keep a linear history on the trunk branch, we will normally squash and rebase your branch history.

Communication

All details on how to communicate with the project contributors and the community overall can be found at https://selenium.dev/support

1 - Contributing to the Selenium site

How to update the Selenium site pages outside of the documentation

The Selenium site is built with Hugo and the Docsy theme. The site root is the website_and_docs directory. Follow the contribution mechanics to set up your environment and preview your changes with hugo server.

Where things live

WhatWhere
Home pagecontent/_index.<language>.html
Top level pages (downloads, support, projects, sponsors, etc.)content/<page>/_index.html
Blog postscontent/blog/<year>/<post>.md
Page templates (e.g., the downloads page)layouts/<section>/list.html
Shortcodeslayouts/shortcodes/
Partials (navbar, footer, announcement banner, etc.)layouts/partials/
Images and other static filesstatic/ (e.g., static/images/)
Stylesassets/scss/
Structured data (e.g., sponsors)data/
Site configuration and menushugo.toml

Some pages have most of their content in the template instead of the Markdown file. For example, the content of the Downloads page lives in layouts/downloads/list.html.

Blog posts

Add a new Markdown file under content/blog/<year>/. Copy the front matter of a recent post and update the title, linkTitle, date, tags, categories, author, and description. To use a custom image when the post is shared on social media, add it under static/images/blog/<year>/ and reference it in the images front matter key.

Translations

The home page and the documentation are translated. Most of the other site pages, including the blog, are only available in English. When you change text on a translated page, see Translations in the style guide.

Checking your changes

Site changes are not covered by tests, so preview every page you changed with hugo server. Every pull request gets a Netlify deploy preview; check it before asking for a review.

2 - Contributing to the Selenium documentation

How the Selenium documentation is organized and how to change it

The documentation lives in website_and_docs/content/documentation. Follow the contribution mechanics to set up your environment and preview your changes with hugo server.

Structure

Each directory is a section of the documentation, and its _index.<language>.md file is the section landing page. Each page has one file per language:

  • <page>.en.md
  • <page>.ja.md
  • <page>.pt-br.md
  • <page>.zh-cn.md

When you add a page, add a file for each language. If you are not translating the content, copy the English text into the other language files.

Each page starts with front matter like this:

---
title: "Sentence capitalization title that describes the page"
linkTitle: "Short Title"
weight: 4
description: >
  One sentence summary of the page.
---

weight defines the order of the page in the navigation. See Capitalization of titles for the title and linkTitle conventions.

Writing

  • Keep the prose language independent. Anything specific to a language binding goes inside code tabs.
  • Follow the style guide for line length, alerts, and code tabs.
  • Mark missing content with the alerts described in the style guide, so others know where help is needed.
  • Link to other documentation pages with the ref shortcode, e.g., [Waits]({{< ref "waits.md" >}}), so broken links fail the build.

Code in the documentation

Code shown in the documentation must come from runnable examples. See Code examples for how to create them and render them on a page.

Translations

See Translations in the style guide.

3 - Contributing code examples

How to create runnable code examples and render them in the documentation

We want to be able to run all of our code examples in the CI to ensure that people can copy, paste and execute everything on the site. So the code lives in the examples directory, and the documentation renders it from there.

Creating examples

Examples that need to be added are marked with:

Add Example

Each page in the documentation correlates to a test file in each of the languages, and should follow naming conventions. For instance examples for this page https://www.selenium.dev/documentation/webdriver/browsers/chrome/ get added in these files:

  • "/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java"
  • "/examples/python/tests/browsers/test_chrome.py"
  • "/examples/dotnet/SeleniumDocs/Browsers/ChromeTest.cs"
  • "/examples/ruby/spec/browsers/chrome_spec.rb"
  • "/examples/javascript/test/browser/chromeSpecificCaps.spec.js"
  • "/examples/kotlin/src/test/kotlin/dev/selenium/browsers/ChromeTest.kt"

Follow these guidelines when writing an example:

  • Each example gets its own test. This keeps the example focused and lets the documentation point to exactly the lines that matter.
  • Use the Selenium test pages. Examples need a web page to work against. Use the pages available at https://www.selenium.dev/selenium/web/ instead of third party sites, which can change or go offline and break the examples.
  • Assert the outcome. Each test should have an assertion that verifies the code works as intended, so that a broken example fails the CI.
  • Keep the shown code free of test noise. Write the test so that the lines shown in the documentation are only the Selenium code the reader needs. Assertions and test setup are not shown, unless the assertion is the clearest way to show the result of the command (e.g., the value returned by a getter).
  • Run the tests. Run the tests for each language you changed locally, and make sure they pass in the CI. Each language directory in the examples directory has a README with the instructions to run its tests.

Moving examples

Examples that need to be moved are marked with:

Move Code

These are code examples that are written directly in the Markdown file. Everything from Creating examples applies: move the code into a test, then render it with gh-codeblock as described below.

Rendering examples

Once the code is in its own test, it needs to be referenced in the Markdown file with the gh-codeblock shortcode. For example, the tab in Ruby would look like this:

    {{< tab header="Ruby" >}}
    {{< gh-codeblock path="/examples/ruby/spec/browsers/chrome_spec.rb#L8-L9" >}}
    {{< /tab >}}

See Reference GitHub Examples in the style guide for the complete tabpane syntax. Keep in mind the following:

  • Show only the relevant lines. The line numbers at the end of the path (#L8-L9) select the lines that are displayed. Use a single line (#L8) or a range of lines (#L8-L9). Readers can click “View Complete Code” or “View on GitHub” to see the full test.
  • One range per code block. A gh-codeblock displays one continuous range of lines. If the lines you want to show are not next to each other, reorganize the test so they are, or use one gh-codeblock for each range.
  • Use text=true. By default, the tabs get formatted for code, so to use markdown or other shortcode statements (like gh-codeblock) it needs to be declared as text. For most examples, the tabpane declares the text=true, but if some of the tabs have code examples, the tabpane cannot specify it, and it must be specified in the tabs that do not need automatic code formatting.
  • Do not indent the gh-codeblock line. An indented line is rendered as a Markdown code block instead of running the shortcode.
  • Keep line numbers up to date. When you add, remove or move lines in an example file, every gh-codeblock that points to that file below the change needs new line numbers. Search website_and_docs/content for the file path, and check all languages of the page.
  • Add the example to all translations. Update the gh-codeblock references in the .ja.md, .pt-br.md and .zh-cn.md files of the page too.