WebDriver Keyword Automated Testing Framework

Overview

The Keyword Framework has been created to expand automated functional testing to a broader range of users, and to make people familiar with automation more productive. The Framework enables users to create test cases in a pipe-delimited format, which is read by the framework and passed on to the Selenium (webDriver) automated testing tool as an automated script. Users define their actions in simple terms understood by the framework, eliminating the need to learn a complex programming language.

Instructions for Creating Tests

Please find a sample script here. Scripts contain series of commands that tell the framework how to test the application. These commands are pipe-delimited, with one line per command. The first item on a line must be a recognized keyword. The list of recognized keywords can be found here. A good way to create a script is to walk through a manual test case, creating a script that mimics your actions. When you click on a button with a label of 'Login', just add the given command to your file:

click|Login

If you wish to verify the following text appears on your page "my sample text", add the following line:

verifyText|my sample text

If you wish to use a variable value, Add a $ to a variable name, like this:

click|$mySite

This line will read a variable called 'mySite' from a variables file and click on the contents of that variable.  This is useful in cases where you want to quickly change users or sites across multiple scripts.  The variables file will need to be specified in your parameters file, described in the 'Instructions for Running Tests' section below.

Once your script is completed, save it as a plain-text file. If your script(s) uploads any files, put these files in a common directory. The framework requires that a text file exist that contains the absolute path to your scripts and the order of their execution. For example, a test list might exist that contains the following lines:

  • /storage/code/svn/edu/umich/keyword/csv/gradebook/01_Gradebook_Instructor_AddItem.csv
  • /storage/code/svn/edu/umich/keyword/csv/gradebook/02_Gradebook_Instructor_EditItem.csv
  • /storage/code/svn/edu/umich/keyword/csv/gradebook/03_Gradebook_Instructor_ImportGrades.csv
  • /storage/code/svn/edu/umich/keyword/csv/gradebook/04_Gradebook_Instructor_ChangeGradeOptions.csv
  • /storage/code/svn/edu/umich/keyword/csv/gradebook/05_Gradebook_Instructor_OverrideGrades.csv

Each of the scripts will be executed by the framework in the order it appears in the test list.

Instructions for Running Tests

The Keyword Framework is a standalone java application, written using Java 1.6. You will need to have an installed java jvm 1.6 or greater on your computer.

A parameters.txt file must be present in the same directory as the keywordFramework.jar file, containing the following information:

  • os - This can either be 'Windows', or anything else. This is used internally by the framework to understand the orientation of forward and backward slashes "/" and "\". Essentially the value of 'Windows' instructors the framework to convert forward-slashes to back-slashes. Any other term is ignored.  Default is 'mac'.
  • browser - Can be 'firefox', 'internet explorer', or 'chrome'. Default is '*firefox'.  NOTE: There is currently a bug in the Chrome driver that breaks file uploads.  WebDriver is aware of this and should be releasing a patch in early Fall 2011.  Also, IE users will want to make sure their security options are set according to this article.
  • testList - The plain text file that indicates which tests you wish to run and the absolute path to those scripts.
  • variablesFile - The file which houses your variables.  It can sit anywhere on your local machine.  There is no default
  • downloadDirectory - The directory which will store downloads temporarily while they are verified.  Note: This setting cannot modify the default download directory within the Chrome browser.  Users who are testing Chrome should set this setting to your browser's current download directory.
  • logDirectory - The directory which will store your log files. All tests for a given run will be stored in a sub-directory named after the time at which the tests began.
  • fileDirectory - The directory which stores files that are used as uploads by test scripts. This is all the directory for storing baseline versions of files that will be compared against download files to verify that the correct files have been downloaded.

A sample parameters file for Linux users can be found here.

Once your scripts are written, and your parameters file is created, you are ready to run your tests.  Open a command-line and navigate to the directory which contains the keywordFramework.jar file and enter the following line:

java -jar keywordFramework.jar

The framework needs a few seconds to get started, but eventually a browser will launch and your test scripts should start to run.  By default, the browser is closed at the end of each test script and re-launched before the next one.  Don't be alarmed if you see browsers opening and closing frequently.

Instructions for Viewing Test Results

All log files are stored in the directory indicated by your logDirectory parameter. Separate directories (named after the timestamp of your test run) contain the logs of each test run. Within each sub-folder is a file called report.txt, which show which test cases passed and failed, as well as summary stats for all cases.  There are also individual log files for each test case.  In the case of failure, a screenshot is collected from the browser at the time of failure and stored in the same sub-directory as the log files.  The screenshot is named after the failed test case.

Tips and Tricks

Windows users attempting to verify downloaded pdfs may notice that your files open in your browser instead of downloading.  Within Chrome, this behavior can be modified by opening content settings and disabling plug-ins for pdfs.  I had two that needed disabling.

Download

The Keyword Framework jar can be download here.  The parameters files can be found here.

The source code is available here. Only the java files, and dependencies, are used in building the jar.

Some sample scripts are available here. These scripts are designed to work with the University of Michigan's branded version of Sakai (CTools). They will need to be modified to work in a Sakai QA environment.