Permalink
Browse files

Modified how Travis CI is used with the project. (#716)

* Modified how Travis CI is used with the project.

Travis does not allow, for securirty reasons, PR buils to access
encrypted data. Project stores the Sacuce Labs credentials in
encrypted format in Travis settings and therefore builds from PR can
not use the browsers from Sauce Labs. Changed CI configuration and
run_tests.py to use Trvis Chrome browser for PR buils. Also configured
Travis corn to test from master periodically and to use different
browsers from the Sauce Labs.

Did take Python argparse in use and therefore passing arbitary
pybot and rebot arguments is not anymore possible. But now it is
possible also to use Sauce Labs from when running test from
local computer.

* Changed selenium 3 run from Python 3 to Python 2.

* Changed chrome browser always to run from Travis

* Downloading chrome driver and putting it to path

* Allowing Sauce Labs to choose chrome version and the OS

* Updated based on review

* Enhanced documation and Robot Framework command line args

Not it is possible to pass Robot Framework command line
arguments as last argument to run_tests.py command.

* Added support for "py -2" for windows and test/README.rst

* Removed env.py

* Spell checks performed

* Fixed documentation based on comments

* Added doc string to the module

Also the argperser is also using the module doc string.

* Fixed based on comments

* Fixed based on comments
  • Loading branch information...
1 parent 88f733c commit 0b545d18bfbc7c9527f59e3d5685866c207e3c36 @aaltat aaltat committed on GitHub Jan 11, 2017
Showing with 266 additions and 169 deletions.
  1. +31 −40 .travis.yml
  2. +3 −36 BUILD.rst
  3. +85 −0 test/README.rst
  4. +0 −20 test/env.py
  5. +147 −73 test/run_tests.py
View
@@ -1,52 +1,43 @@
-addons:
- firefox: latest-esr
language: python
-sudo: false
+sudo: required
+dist: trusty
+addons:
+ apt:
+ sources:
+ - google-chrome
+ packages:
+ - google-chrome-stable
+before_install:
+ - CDVERSION=`curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
+ - wget http://chromedriver.storage.googleapis.com/$CDVERSION/chromedriver_linux64.zip
+ - unzip chromedriver_linux64.zip
+ - sudo chmod u+x chromedriver
+ - sudo mv chromedriver /usr/bin/
install:
- pip install .
- pip install -r requirements.txt
- pip install -r requirements-dev.txt
-before_script:
- - "export DISPLAY=:99.0"
- - "sh -e /etc/init.d/xvfb start"
-script:
- - "if [[ -n ${SELENIUM_VERSION+x} ]]; then pip install -U selenium==${SELENIUM_VERSION}; fi"
- - "python test/run_tests.py python \"$BROWSER\""
-env:
- global:
- - secure: "QyY0j8C+hVhsGLv4YU0UMvLm5wBDg6xT5J0Ee77C/JAQ6vcdCMpTfWI8oDxTZb7pBhpDkYuNe747yCYF5PrdBYQbO08FilxctReuJfMXcH44rZC5q49mUmPamkvg1LkzIWuC1s9uKnjlvyDT5ojuPXZl2Vn0gIhSIg+yOyBkM1U="
- - secure: "HJaJTYauaBZODMDkbnRVsiCk+t2uVtztkkJ5V4dXSnE1uIBms2PVbufQwb+YNvzHkGheLtpnt/hLM1HhmSFgUtOCf+eumQ6kaLR2KRVEysXwWJzgZoLBidNBOy5rvAIsc9JJbDaIgYVGzyaJGTP9AMb8CyvIPE//lH10sf+GB7g="
matrix:
include:
- - os: linux
- env:
- - BROWSER=firefox
- - SELENIUM_VERSION=2.53.6
- addons:
- firefox: "47.0.1"
- python: "2.7"
- - os: linux
+ - python: "2.7" # For PR and cron
env:
- BROWSER=chrome
- addons:
- sauce_connect: true
- python: "2.7"
- - os: linux
+ - SELENIUM=2.53.6
+ - python: "3.3" # For PR and cron
env:
- - BROWSER=firefox
- - SELENIUM_VERSION=2.53.6
- addons:
- sauce_connect: true
- python: "3.4"
- - os: linux
+ - BROWSER=chrome
+ - SELENIUM=2.53.6
+ - python: "2.7" # For PR and cron
env:
- - BROWSER="internet explorer"
- addons:
- sauce_connect: true
- python: "2.7"
- - os: linux
+ - BROWSER=chrome
+ - SELENIUM=3.0.2
+ - python: "3.3" # For cron only
env:
- - BROWSER=safari
- addons:
- sauce_connect: true
- python: "2.7"
+ - BROWSER=firefox
+ - SELENIUM=2.53.6
+before_script:
+ - "export DISPLAY=:99.0"
+ - "sh -e /etc/init.d/xvfb start"
+ - pip install selenium==$SELENIUM
+script:
+ - python test/run_tests.py $BROWSER
View
@@ -26,44 +26,11 @@ test/
Unit and Acceptance Tests
-------------------------
+To run tests give command::
-The test directory contains everything needed to run Selenium2Library
-tests with Robot Framework. This includes:
+ python test/run_tests.py <browser>
-- Unit tests under `unit` directory.
-- Acceptance tests written with Robot Framework under `acceptance`
- directory
-- A very simple httpserver.py which is used to serve the html for tests in
- `resources/testserver`
-- A collection of simple html files under 'resources/html' directory
-- Start-up scripts for executing the tests
-- A copy of statuschecker.py for checking logged messages after the
- execution, which requires the tests to run with log level DEBUG
-
-To run unit and acceptance tests, run::
-
- python test/run_tests.py python|jython ff|ie|chrome [options]
-
-The first argument to the script defines the interpreter to be used
-to run Robot. The second argument defines the browser to be used,
-using the same browser tokens that you would use in your Robot
-tests.
-
-Due to the structure of the tests, the directory containg the test
-case files (`acceptance`) is always given to Robot as test data path.
-To run only a subset of test cases, Robot command line arguments
---test, --suite, --include and --exclude may be used.
-
-Examples::
-
- # Run all tests with Python and Firefox
- python test/run_tests.py python ff
- # Run only test suite `javascript` with Jython and Internet Explorer
- python test/run_tests.py jython ie -s javascript
-
-To run just the unit tests, run::
-
- python test/run_unit_tests.py
+More details in `<test/README.rst>`__
Debugging Selenium2Library
View
@@ -0,0 +1,85 @@
+Testing and debugging
+=====================
+Requirements
+------------
+Before running the test, install the dependencies::
+
+ pip install -r requirements.txt
+ pip install -r requirements-dev.txt
+
+
+Unit and Acceptance Tests
+-------------------------
+
+The test directory contains everything needed to run Selenium2Library
+tests with Robot Framework. This includes:
+
+- Unit tests under `unit` directory.
+- Acceptance tests written with Robot Framework under `acceptance`
+ directory
+- A very simple `httpserver.py` which is used to serve the html for tests in
+ `resources/testserver`
+- A collection of simple html files under `resources/html` directory
+- Start-up scripts for executing the tests: `run_tests.py` and
+ `run_unit_tests.py`
+
+To run unit and acceptance tests, run::
+
+ python test/run_tests.py <browser>
+
+Tests are executed using Robot Framework and results verified automatically
+afterwards using `robotstatuschecker` tool. The tool can be installed using
+`pip install robotstatuschecker` and more information about it can be found
+from: https://github.com/robotframework/statuschecker/. Notice that initially
+some tests fail.
+
+Running test with different interpreter
+---------------------------------------
+
+By default the interpreter is set to `python` and it depends on the operating
+system settings, which python is used by default. It is possible to run test
+by using different interpreter by using the `--interpreter` command line
+argument.
+
+Starting from version 2.0 onwards the Selenium2Library is tested by using
+Python 2 and 3. Other interpreters are not tested by the development team.
+
+
+Robot Framework command line arguments
+--------------------------------------
+
+It is possible to pass Robot Framework command line arguments to the test
+execution as last arguments to the `run_tests.py` command. It is recommended
+to use arguments to select required suite or test for the execution when
+developing new functionality for the library. Example like --test, --suite,
+--include and --exclude.
+
+
+Using Sauce Labs for acceptance tests
+-------------------------------------
+
+When running test by using browser from Sauce labs, it is required that the
+Sauce Connect is used. The Sauce Connect allows the browser from Sauce Labs
+reach the acceptance test web server. The acceptance test uses tunnel with
+name `localtunnel` and therefore when establishing the Sauce Connect tunnel
+use the following command::
+
+ bin/sc -u YOUR_USERNAME -k YOUR_ACCESS_KEY -i localtunnel
+
+More details and to download Sauce Connect visit:
+https://wiki.saucelabs.com/display/DOCS/High+Availability+Sauce+Connect+Setup
+
+
+Examples
+--------
+
+Examples::
+
+ run_tests.py chrome
+ run_tests.py --interpreter jython firefox --suite javascript
+ run_tests.py chrome --sauceusername your_username --saucekey account_key --suite javascript
+ run_tests.py --interpreter "py -2" chrome --suite javascript
+
+To run just the unit tests, run::
+
+ python test/run_unit_tests.py
View
@@ -1,20 +0,0 @@
-import os
-import sys
-
-ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
-UNIT_TEST_DIR = os.path.join(ROOT_DIR, "unit")
-ACCEPTANCE_TEST_DIR = os.path.join(ROOT_DIR, "acceptance")
-RESOURCES_DIR = os.path.join(ROOT_DIR, "resources")
-TEST_LIBS_DIR = os.path.join(RESOURCES_DIR, "testlibs")
-RESULTS_DIR = os.path.join(ROOT_DIR, "results")
-HTTP_SERVER_FILE = os.path.join(RESOURCES_DIR, "testserver", "testserver.py")
-SRC_DIR = os.path.join(ROOT_DIR, "..", "src")
-
-TRAVIS = os.environ.get("TRAVIS", None)
-TRAVIS_JOB_NUMBER = os.environ.get("TRAVIS_JOB_NUMBER")
-SAUCE_USERNAME = os.environ.get("SAUCE_USERNAME")
-SAUCE_ACCESS_KEY = os.environ.get("SAUCE_ACCESS_KEY")
-
-
-sys.path.insert(0, SRC_DIR)
-sys.path.append(UNIT_TEST_DIR)
Oops, something went wrong.

0 comments on commit 0b545d1

Please sign in to comment.