Aiding the documentation effort

Selenium is a very old project. The original work on it started in 2004. As a result, there have been many changes over the years and, as with all big and old projects, the documentation hasn't always stayed up to date or been as clear as it could be.

If you spend time going through the documentation, you will probably encounter the following:

  • Minor errors (such as typos, grammar mistakes, and so on)
  • Gaps where some available functionality has never been written about
  • Documentation that is either no longer correct or no longer relevant

Documentation always needs to be updated, and there are never enough people to do it. This is the perfect place to start contributing to the Selenium project. The documentation is roughly split into two areas. There is the existing Selenium HQ site, which contains the current documentation (for more information, visit http://docs.seleniumhq.org/docs/). There is also the new documentation project, which was created in 2013. The idea was to start writing the documentation from scratch (visit http://seleniumhq.github.io/docs/ for additional information).

The Selenium HQ site is more than just documentation. Don't think that you are limited to just enhancing the documentation. You are quite welcome to contribute a change to any aspect of the site.

Earlier in this chapter, we cloned a copy of the existing SeleniumHQ website. Hopefully, you have already examined and played around with it a bit. If we now want to take the next step and start contributing, we will need to turn our clone into a fork. The process is very simple.

 First of all, go to the GitHub page for the documentation and then click on the Fork button:

GitHub will then do all the work for you. When it has finished, it will load the forked version of the site:

Note that on the right-hand side, you now have your own unique clone URL. There are two things that you can do at this point:

  • Delete your existing local copy of the documentation and then clone your fork
  • Change your remote to point at the new fork on GitHub

Deleting your local copy is easy. Just go to the parent directory that you originally ran your clone command in and use the following command:

rm -r www.seleniumhq.org
git clone <your personal clone url>

You will now have the forked version of the Selenium website cloned. You just need to set up an upstream remote, as shown in the following section.

Be very careful whenever you use an rm -r or rm -rf command. The -r stands for recursive (that is, it will delete the directory that you have told it to delete along with the files and directories in the original directory that you specified). The -f stands for force. It will do everything it can to delete the files. If you aren't paying attention and you run the command with elevated privileges, it's very easy to remove the wrong thing, or even everything on your hard drive by mistake!

Let's assume that you have some changes that you don't want to lose. The easiest thing to do in this situation is just change your remote.

We are going to do this in a couple of steps. First of all, we need to have a look at what we currently have set up in Git. We can do this by using the following command to list our remotes:

git remote -v

You will get something that looks like this:

We are going to change the existing remote to upstream. This will allow us to pull down any changes that are made in SeleniumHQ's copy of the code:

git remote add upstream https://github.com/SeleniumHQ/www.seleniumhq.org.git

If you check your remotes again, you will now have an upstream and an origin both pointing at the same thing:

Now, if you want to get your fork up-to-date with SeleniumHQ's copy of the code, all you need to do is use the following command:

git fetch upstream
    
git rebase upstream/master

This will pull down the latest code from the origin and then rebase it onto your current branch (in this case, origin/master).

We have used quite a few different Git commands so far; if you haven't used Git before you may be getting a bit lost. There is a good basic tutorial available at https://git-scm.com/docs/gittutorial which should give you most of the basics. Then you'll probably want to understand rebasing: https://git-scm.com/book/en/v2/Git-Branching-Rebasing. Git is a very powerful version control system, but it can be a little overwhelming at first if you don't know where to get more information.

The final step is to change our remote to point at the fork. First, copy the clone URL for your fork and then run the following command:

git remote set-url origin 
[email protected]:Ardesco/www.seleniumhq.org.git

Your remotes should now look like this:

You are now ready to make changes to the documentation. When you are happy with a change, you can create a pull request to submit it back to the Selenium developers.

It's always useful to create a new branch for the changes you make. When you perform a pull request, it is not for a static piece of code. You are requesting that the branch that you are currently working on should be pulled in. This means that if you make any changes to the branch after making your pull request, they will also be added to the list of things that are being offered. Having a separate branch for each pull request allows you to easily isolate changes.

So far, we have been looking at the old site. Also, we did briefly mention earlier that there is a new documentation project. If you want to add documentation, this is probably the best place to start. To do this, you will need to clone the new documentation project (for more information, visit https://github.com/SeleniumHQ/docs.git).

The process is basically identical to the one that we followed to clone the Selenium website. Once you are done, you are all ready to make changes to the document. Why not start updating the documentations and creating pull requests today?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.64.128