Skip to content

Commit ce6cba8

Browse files
author
Brandon Duffany
committed
Update documentation with docker instructions
1 parent c9d3277 commit ce6cba8

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

README.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,50 @@
11
# Codebender Selenium Tests
22

33
This repo contains Selenium tests for the codebender website. The tests are
4-
written in Python 3, and utilize pytest as a testing framework and Selenium
4+
written in Python 2, and utilize pytest as a testing framework and Selenium
55
for browser automation.
66

77
## Running Tests
88

9-
### Dependencies
9+
Tests are run by invoking `tox`. Run `tox --help` to see all the
10+
Codebender-specific arguments that can be passed to `py.test`.
1011

11-
To run these tests, you'll need to have Python 3 installed. In addition, it is
12-
advantageous to have pip, a package manager for Python, in order to install
13-
dependencies.
12+
In addition to these arguments, there are certain environment variables that
13+
should be set when running tests:
1414

15-
Notably, the pip2 (for Python 2) and pip3 (for Python 3) packages both attempt
16-
to link `/usr/local/bin/pip` to the `pip2` or `pip3` executable, respectively.
17-
To deal with this, you could explicitly type out `pip3` or `pip2` instead of
18-
`pip` whenever you use pip via the command line. (It may be best to just remove
19-
`/usr/local/bin/pip` entirely).
15+
- `CODEBENDER_SELENIUM_HUB_URL`: the URL of the Selenium Hub. If you are using
16+
SauceLabs, the URL has the following format:
17+
`http://{USERNAME}:{ACCESS_KEY}@ondemand.saucelabs.com:80/wd/hub`. You can
18+
also use a [docker-selenium](https://github.com/SeleniumHQ/docker-selenium)
19+
hub. In that case, it is necessary to link the docker-selenium instance to the
20+
Docker instance from which tests are running.
21+
- `CODEBENDER_TEST_USER`: username that the webdriver will use to log into the
22+
site in order to perform tests.
23+
- `CODEBENDER_TEST_PASS`: password for `CODEBENDER_TEST_USER`.
2024

21-
To install `pip` in Ubuntu, run `$ sudo apt-get install python3
22-
python3-setuptools`, then `$ sudo easy_install3 pip`.
25+
Rather than invoking `tox` directly, the easiest way to run tests is with
26+
Docker. If you are not familiar with Docker, please consult the
27+
[documentation](http://docs.docker.com/) for an introduction.
2328

24-
After getting set up with pip and cloning the seleniumTests repo, you should
25-
make sure to install all the seleniumTests dependencies by `cd`ing to your local
26-
clone of the repo and running `$ sudo pip3 install -r requirements-dev.txt`.
29+
First, build the image with `$ docker build . -t codebender/selenium`.
2730

28-
### Invoking Tests via `tox`
31+
Then invoke `tox` via `docker run`. Here is a sample command to run all tests,
32+
where the Codebender server is running at `http://192.168.1.2:8080`:
2933

30-
After installing dependencies, you should have the `tox` command available. To
31-
run all of the tests, you can simply run `$ tox` from within the cloned repo.
34+
```
35+
$ docker run -e CODEBENDER_SELENIUM_HUB_URL=http://johndoe:[email protected]:80/wd/hub \
36+
-e CODEBENDER_TEST_USER=tester \
37+
-e CODEBENDER_TEST_PASS=1234 \
38+
-it codebender/selenium \
39+
tox -- --url http://192.168.1.2:8080 --source bachelor
40+
```
3241

33-
You can also run individual tests by providing the appropriate directory or
34-
filename as an argument, for example: `$ tox tests/sketch`.
42+
### Running Tests Manually
3543

36-
Invoking tox will also run `flake8`, which is essentially a lint checker for
37-
Python. It is best to fix any issues reported by `flake8` before committing
38-
to the repo. It can be run on its own via the command `$ flake8`.
44+
The recommended way of running tests is with Docker. If you would like to
45+
manually provision your machine to be able to run tests, you can use the
46+
Dockerfile as a step-by-step guide for provisioning. Then invoke `tox` to run
47+
tests.
3948

4049
#### Specifying a URL for Tests
4150

@@ -105,6 +114,11 @@ The most important class is `SeleniumTestCase`, which all of the unit test cases
105114
inherit from. This grants them access (via `self`) to a number of methods and
106115
attributes that are useful for performing codebender-specific actions.
107116

117+
**`codebender_testing/capabilities.yaml`** defines a list of `capabilities` to
118+
be passed as arguments when instantiating remote webdrivers. In particular, it
119+
specifies the web browsers that we would like to use. Consult this file for more
120+
information.
121+
108122
#### `batch/`
109123

110124
The `batch/` directory contains any executable scripts not directly used to

0 commit comments

Comments
 (0)