WTF - Web Test Framework

## Project description

WTF - Web Test Framework
======
https://github.com/wiredrive/wtframework

Web Test Framework (referred to as WTF for short) provides a structured testing
framework for testing a Web Applications in a maintainable manner. It helps QA/SDET
professionals quickly setup and develop acceptance level web tests. The aim of this
project is to provide a structured layered framework for web testing like how Django
and other modern MVC frameworks provide a structured way of developing web applications.

Install
=======

Requirements
* PyPi (pip) - http://www.pip-installer.org/en/latest/

Installation via PYPI

pip install wtframework

=======================

Run the following command to initialize an empty project structure for a WTF test.

wtf_init.py YourProjectName --withexamples

Windows Note: .py files may not be executable, you may have to prefix these commands
with the python command.
python wtf_init.py YourProject --withexamples

This will create an the folders and packages of your project. You'll see something like:

/YourProjectName
/assets - place non-code files used in your tests here.
/configs - location of config files.
/data - data files (like CSV files) goes here.
/reference-screenshots - if enabled, reference screenshots are placed here.
/reports - test result XML files will go here when you run tests.
/screenshots - screenshots taken on test failures will go here.
/tests - top level package for your test code.
/flows - high level reuseable multipage flows.
/models - data models go here. (like DataBase ORM code)
/pages - Your page objects go here.
/support - reuseable support utility functions go here.
/testdata - custom code for working with test data.
/tests - Your high level tests will go here.

Next you'll need to setup your python path.

export PYTHONPATH=\$PYTHONPATH:path/to/project/

On windows:

set PYTHONPATH=%PYTHONPATH%;c:\path\to\project\

Now the directory structure and your python path is setup so nosetests can run tests
you write in the WTF framework.

Configuring Eclipse/PyDev Environment
-------------------------------------
2. Install the PyDev plugin. http://pydev.org/
3. Goto Eclipse -> Preferences (Or on windows, this Window -> Preferences )
4. Goto PyDev -> Interpretor Python then open the Libraries tab.
5. Add you python site-packages (where pip installs packages to)
At this point your PyDev enviornment should be able to recognize your
installed packages.
6. In Eclipse, goto "File" and create a new PyDev project.
your Project folder. This should create the PyDev project files necessary to
allow you to work on this project as a PyDev project.

==================

./runtests.py [-c ConfigFile]

This will execute the unit tests in the tests/tests folder. The test results will be
written to reports/, any screenshots taken during errors will be stored in the
screenshots/ folder.

WTF Framework Features
======================

PageObjects
-----------
WTF provides handy generators for quickly generating PageObjects. The following
command will generate a PageObject given a name and URL. To use PageObject generator,
type the following command.

wtf_tools.py generate-page W3FormSamplePage http://www.w3schools.com/html/html_forms.asp

This will do the following:

1. Creates a new file named after your page object.
2. Within the file, it'll create a new class that extends PageObject base class.
3. It will generate a page validation method, which will validate the page by url.
4. It will scan the target page location for non-hidden input tags, and create
object mappings for those inputs. The 'name' attribute will be used for identifying
and naming the mapped objects.

Note: I have not implemented any sort of session support yet. So this will not work in
pages that require a session.

from wtframework.wtf.web.PageFactory import PageFactory
...

Alternatively, you can use the WebUtils to wait for the page to load. This will allow

from wtframework.wtf.web.WebUtils import WebUtils
...

Note: This will use the PageObject's _validate_page() to check if the page is
matching the expected page. It's good to not use URL validation in cases you expect
the page to take a long time to load, and instead verify on a list of expected
elements you want to have loaded.

Once you have created a PageOjbect, you'll want to go in and edit the file and make any
changes to the mappings and page verification routines. As a good practice, it's good
to write methods to expose your transactional logic as a higher level method call
to avoid cluttering your high level tests and test flows with low level UI logic.

See: http://engineeringquality.blogspot.com/2012/12/python-quick-and-dirty-pageobject.html

Configurable Tests
------------------
Being able to run tests across different environments and settings is a powerful tool.
WTF has a powerful tool for working with configurations called WTF_CONFIG_READER. By
default, it'll look at the default.yaml file in the /configs directory. But you may
specify using other config files by setting the WTF_ENV variable. This is useful to
have different config files for your different test environments. Then in your CI
system, you can just specify which config file to use.

In your tests, you can pull the values you have stored in your config file using the
WTF_CONFIG_READER like this:

webdriver.get( base_url + "/somelocation" )

This allows you to make your test environment agnostic, runnable across multiple
configurations with just a switch of an environment variable. This is good for storing
environment settings and locations, account information (like DB login), connection
strings, etc...

WTFBaseTest
-----------
WTF framework adds some added functionality like capturing screenshots to the base
Unit test. In order to leverage this functionality, your tests should extend the
WTFBaseTest base class.

WTFBaseTest comes with a ScreenCaptureTestWatcher. You may also implement your own
test watcher by extending TestWatcher class, and overriding it's methods. This is
useful for creating your own base test with your own actions such as recording results
to Test Case Management upon test completion. If you like to do without the added
functionality of WTFBaseTest, you can use WatchedTestCase and extend it.

Data Driven Testing
-------------------
WTF framework provides a easy way of doing Data-Driven-Tests using CSV files. Data
files are stored in the data/ folder, and can be easily accessed using the utility
class WTF_DATA_MANAGER.get_data_file("nameOfCsvFile"). You can iterate a single test
over those CSV row values by using the @ddt and @csvdata decorators.

You can have a csv file with first row the column headers like, `data/animals.csv'

Animal,Type,Size
Dog,Mammal,3.0
Cat,Mammal,1.5
Lizzard,Reptile,2.0

Then in YourTest.py, you can reference these values as follows:

# Use @ddt decorator at the class level.
@ddt

# Then use the @csvdata decorator to flag a test method data driven.
@csvdata("testdata.csv", "testenv")
#Then in your test, you can use the parameter passed into your test
animal = parameter_dic['Animal']
type = parameter_dic['Type']
size = parameter_dict['Size']
...

Misc
====

-------
This framework is free and open source. Licensed under GPLv3. See 'LICENSE.TXT' for

How to Contribute
-----------------
You can fork this repository. To get the unit tests not marked as skipped running,
you'll need to edit or supply your own config file with values for the selenium settings.

Development on this project is currently done using NVIE branching model.
http://nvie.com/posts/a-successful-git-branching-model/

To submit code changes, please submit pull requests against the development branch.

Credits
------------
David Lai <david@wiredrive.com>

0.4.11

0.4.10

0.4.9

0.4.8

0.4.7

0.4.6

0.4.5

0.4.4

0.4.2

0.4.0

0.3.12

0.3.11

0.3.10

0.3.9

0.3.8

0.3.7

0.3.6

0.3.5

0.3.4

0.3.3

0.3.2

0.3.1

0.3.0

0.2.23

0.2.22

0.2.21

0.2.19

0.2.18

0.2.16

0.2.15

0.2.13

0.2.12

0.2.11

0.2.9

0.2.8

0.2.7

0.2.6

0.2.5

0.2.4

0.2.3

0.2.2

0.2.1

0.2.0

This version

0.1.0

0.0.17

0.0.16

0.0.15

0.0.14

0.0.13

0.0.12

0.0.11

0.0.10

0.0.8

0.0.7

0.0.6

0.0.3

0.0.2

0.0.1