This is the automation testing framework for CloudForms, including SystemEngine, CloudEngine and upstream projects Katello, Aeolus and Headpin:
This test framework was originally written for Katello and headpin, and extended by the Red Hat CloudForms QE Integration team. Tests use Mozilla's pytest-mozwebqa plugin.
Current documentation is hosted here.
Dependencies and Installation
- selenium webdriver or selenium server
Clone this project and install dependencies. Dependencies may be installed by running
pip-python install -r ./requirements.txt from the root of the project. A customized dataset may be generated by editting
data/template_data.py and then executing
These tests assume a fresh install of the product(s) that are accessible from the machine running the tests.
There are two ways to run Selenium tests.
- Use the Selenium WebDriver. Executing the tests with argument
--driver=firefoxallows for simple test runs. This is the method most commonly used during development.
- Use the Selenium Server. Running a standalone Selenium Server supports test distribution on multiple hosts.
To start the Selenium Server for local testing:
java -jar /path/to/your/selenium/selenium-X.Y.jar \
See Selenium documentation for more details.
py.test --driver=firefox --baseurl=https://<FQDN>/conductor|katello --project=[project] -q testdir/path/my_test_file.py
--driver=firefoxAllows tests to be run without a separate Selenium server running.
--baseurl=...FQDN of product under test. Include
--product=katello|aeolus|sam|cfse|cfceSpecify product under test.
-k [test_keyword]Test keyword to run specific tests.
-m <marker>For running tests tagged with py.test markers.
See py.test documentation for more information.
About the Files
[project]/tests/test_file.py Test code goes here.
pages/page.py Setup methods to use throughout the page objects. By inheritance these methods are accessible in other page objects. It is important not to include locators or site specific functions in this file. Generally the functions in this file are common across our projects and don't change often.
pages/base.py Page object helper functions that are global across the whole site.
[project]/pages/my_page.py This is a page object file that represents a page on the website. Page-specific methods go here. It inherits the base.py class and inturn all of the methods that base.py has access to.
api/ API helper methods.
credentials.yaml Not currently in use. Store the credentials to log into the site with. The mozwebqa plugin will parse this file and make the values available inside the tests.
conftest.py Specify custom command-line options.
mozwebqa.cfg The mozwebqa plugin will read the parameters in this file and automatically add them onto the py.test command line. It is handy for parameters that are constant like --browsername=firefox
generate_dataset.py Standalone script to generate semi-random data file. Data derived from lists in
data/large_dataset.py Dataset generated from
data/private_data.ini Private cloud provider credentials. Update before running provider tests.
data/manifests/ Content provider manifest.zip files.
requirements.txt Lists required packages. Running
sudo pip install -r requirements.txt (Mac/Linux) will automatically download and install the packages in this file. We recommend 'pinning' the packages to a specific version, for example pytest==2.1.3. This decreases the chance that a change to py.test will affect your test suite.
Interactive Test Development
Developing Selenium tests is tricky and requires some trial and error. Launching a whole test just to see if your last code edit works takes a long time. A quicker way is to use the interactive Python shell (or even better, IPython for auto-complete) to start an interactive webdriver session.
$ python >>> from selenium import webdriver >>> url = 'https://myUrl/aeolus' >>> driver = webdriver.Firefox() >>> driver.get(url)
A Firefox browser window should open to the URL. You can now interact with the new browser window (login, nav to page you're working on, inspect elements). Then try a locator and see if it works.
>>> driver.find_elements_by_css_selector('li#promotions') >>> [<selenium.webdriver.remote.webelement.WebElement at 0x1a42e50>] # valid
Once your selector code is valid you can add to your code and keep going!