Selenium Tests for MozTrap
Перейти к файлу
Matt Brandt 42b20602fb Merge pull request #156 from justinpotts/fix_flake8
Fixed Flake8 errors
2015-03-05 11:08:52 -07:00
mocks Fixed Flake8 errors 2015-03-05 11:47:24 -06:00
pages Fixed Flake8 errors 2015-03-05 11:47:24 -06:00
tests Fixed Flake8 errors 2015-03-05 11:47:24 -06:00
.gitignore Update gitignore 2012-06-21 16:21:47 +01:00
README.md Fix link to pytest-mozwebqa to be from /mozilla repo-owner 2015-02-06 14:05:27 -08:00
conftest.py Add a finalizer to automatically delete the environment, element and category created by some tests 2013-06-28 08:22:33 -04:00
credentials.yaml Add a shared user for api credentials 2013-05-21 17:19:16 -04:00
mozwebqa.cfg Squashed commit of the following: 2013-04-11 14:45:31 -04:00
requirements.txt Unpinned pytest-mozwebqa 2014-11-23 19:29:58 -05:00

README.md

Selenium Tests for moztrap-dev.allizom.org (MozTrap)

Thank you for checking out Mozilla's MozTrap test suite. Mozilla and the Web QA team are grateful for the help and hard work of many contributors like yourself. The following contributors have submitted pull requests to MozTrap-Tests:

https://github.com/mozilla/moztrap-tests/contributors

Getting involved as a contributor

We love working with contributors to fill out the Selenium test coverage for MozTrap-Tests, but it does require a few skills. You will need to know some Python, some Selenium and you will need some basic familiarity with Github.

If you know some Python, it's worth having a look at the Selenium framework to understand the basic concepts of browser based testing and especially page objects. Our suite uses Selenium WebDriver.

If you need to brush up on programming but are eager to start contributing immediately, please consider helping us find bugs in Mozilla Firefox or find bugs in the Mozilla web-sites tested by the Web QA team.

To brush up on Python skills before engaging with us, Dive Into Python is an excellent resource. MIT also has lecture notes on Python available through their open courseware.The programming concepts you will need to know include functions, working with classes, and some object oriented programming basics.

Questions are always welcome

While we take pains to keep our documentation updated, the best source of information is those of us who work on the project. Don't be afraid to join us in irc.mozilla.org #mozwebqa to ask questions about our Selenium tests. Mozilla also hosts the #mozillians chat room to answer your general questions about contributing to Mozilla.

How to Set up and Build MozTrap Tests Locally

This repository contains Selenium tests used to test the website moztrap-dev.allizom.org.

Mozilla maintains a guide to running Automated tests on our QMO website:

https://quality.mozilla.org/docs/webqa/running-webqa-automated-tests/

This wiki page has some advanced instructions specific to Windows:

https://wiki.mozilla.org/QA_SoftVision_Team/WebQA_Automation

###You will need to install the following:

Git

If you have cloned this project already then you can skip this! GitHub has excellent guides for Windows, MacOSX and Linux.

Python

Before you will be able to run these tests you will need to have Python 2.6 or Python 2.7 installed.

Install pip (for managing Python packages):

sudo easy_install pip

or

sudo apt-get install python-pip

####Virtualenv and Virtualenvwrapper (Optional/Intermediate level) While most of us have had some experience using virtual machines, virtualenv is something else entirely. It's used to keep libraries that you install from clashing and messing up your local environment. After installing virtualenv, installing virtualenvwrapper will give you some nice commands to use with virtualenvwrapper.

Installing dependencies

If you are using virtualenv, create and activate the virtualenv, then run the following in the project root:

pip install -r requirements.txt

If you are not using virtualenv, run the following in the project root to install dependencies globally:

sudo pip install -r requirements.txt

####Initializing git submodules Be sure to retrieve the git submodules by issuing this command at the project root:

git submodule update --init

Running tests locally

Tests are run using the py.test library. You will find examples here for running all of the tests, tests in one file and running a single test.

WebDriver does not need a Selenium Server or Grid to run so these examples bypass this step and just use the --driver command.

An example of running all tests without a Selenium Server:

py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml --destructive .

An example of running all of the tests in one file:

py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml tests/test_manage_runs_page.py

An example of running one test in a file:

py.test --driver=firefox --credentials=/path/to/credentials/credentials.yaml tests/test_manage_runs_page.py -k test_that_user_can_create_and_delete_run

The mozwebqa plugin has advanced command line options for reporting and using browsers. See the documentation on [pytest mozwebqa github][pymozwebqa]. [pymozwebqa]: https://github.com/mozilla/pytest-mozwebqa

Moz-grid-config (Optional/Intermediate level)

Prerequisites: Java Runtime Environment, Apache Ant

Moz-grid-config is a project containining our Selenium Grid configuration. It uses Apache Ant to run the Selenium hub or node to the configuration defined in the yaml files.

We recommend git cloning the repository for a couple of reasons:

  1. The commands to launch a node or hub are all pre-configured and as simple as typing ant launch-hub or ant launch-node
  2. The paths to browser binaries and nodes can be stored in configuration (yaml) files
  3. It contains a jar file of the latest Selenium in it's lib directory

(If you prefer to download Selenium it's own, you can do that from here) You will need to make sure that the name of your Firefox application matches one of the names in moz-grid-config/grid_configuration.yml. As an example: even though Firefox typically installs without a version number in the name, moz-grid-config requires it to be named "Firefox ".app on mac.

Writing Tests

If you want to get involved and add more tests then there's just a few things we'd like to ask you to do:

  1. Use the template files for all new tests and page objects
  2. Follow our simple style guide
  3. Fork this project with your own GitHub account
  4. Add your test into the "tests" folder and the necessary methods for it into the appropriate file in "pages"
  5. Make sure all tests are passing and submit a pull request with your changes

License

This software is licensed under the MPL 2.0:

This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.