Download: Framework.zip
Summary
What I am going to discuss here is a standard Page Object Pattern Framework which uses ruby module to store the page objects and EXCEL and YAML to store the data.
What each and every framework requires are, Driver Script, Object repository, Script to read data from Data source(EXCEL, CSV or any other), Files to generate and store reports and finally Test Files.
The framework designed by me contains following things
- Xunit framework: test-unit
- Data Sources: EXCEL and YAML
- Reports: I am using ci_reporter with JUnit ANT target to generate HTML report
- Driver Script: BATCH file which will run tests according to parameter passed and will generate the report.
- Object Repository: Ruby class per page.
For more details you can visit my blog: http://qtp-help.blogspot.com/2011/08/watir-framework.html
What all I require?
- ci_reporter (1.6.5)
- test-unit (2.3.0)
What all files do?
- BaseClassClassMethods (module)
Contains the Statup and Shutdown methods. Startup method will be called before the first test of class in which this module is included called. And Shutdown method will be called after the last test of the class in which this module included called.
- BaseClassInstanceMethods (Module)
Contains Setup, Teardown and Cleanup methods, Setup will be called before each and every test, cleanup and teardown will be called after each and every test method.
- Excel
This class will help to read the excel file. Each and every row is considered as one scenario for testing and every column is given a field name.
- ReadYAML (Module)
This class helps to read the YAML file.
- LoginPage (Module)
This file works as an object repository. You can have corresponding module for each page of your website or single page. I will advice to have different module for each page.
- LoginTestWithExcel
This is the test class which shows how to use all library files and EXCEL as data repository and write the testcase.
- LoginTestWithYAML
This is the test class which shows how to use all library files and YAML as data repository and write the testcase.
- run.rb
This file is actually a driver file which will call all other test files and will generate the XML report
- build.xml
This file contains the ANT target which will generate the JUnit report from generated XML report.
- run.bat
This is the file you require to call to run the testcases
How to Run? 
I have designed a folder structure where, all the library files goes into Libs folder, all the data files (your Excel or YAML files) goes into Data folder, all the page objects definations goes into ObjRepository folder and all the test files goes into Tests folder.
Tests folder has two sub folders Smoke and Regression. You can put all you smoke tests into smoke folder and all your regression tests into regression folder.
To run the test first download the zip files and extract it. Now move to Framework folder from command prompt and use the following commands to run tests.
To run all the tests inside Tests folder enter following commandrun
To run all the tests inside Tests\Smoke folder enter following commandrun smoke
To run all the tests inside Tests\Regression folder enter following commandrun regression
How to customize?
If you want to create one more folder inside Tests folder and want to run all the tests inside that folder you require to edit the following file.
- Run.rb
Question and Feedback
if you have any question or feedback you can post it on my blog here or you can send me mail to: gaurangnshah@gmail.com