Saturday, November 23, 2013

Siesta - Getting Started

Siesta - writing automated tests

Since this page will NOT teach you all you need to know about siesta configuration, settings and functions I strongly recommend that you spend some time reading about siesta.
Here are a few useful links:

Siesta Basics (Briefly)

There are 3 files that needs to be modified when writing a new test in siesta:
  1. index.js
  2. preload.js – This file is loaded before your tests run.
  3. your test file (you can pick any name you want, but keep it meaning-full and in order) for example - Mytestfile.t.js
The files are located in the siesta installation folder:
In your webapp directory you can place your new siesta tests and directories.


Configuration file for the siesta. In order to view and execute a test, you need an entry for your test file in index.js

preload.js (not mandatory)

In your index.js file you can define which files should be loaded before your tests run. You can name it anyway you want, “preload.js” is a nice name. Though this file isn’t mandatory once you start developing more tests you’ll need a common place to store common functions and variables. This is why it is very useful.  

Writing a Test in Siesta - an Example

Create a test file in your webapp folder – Mytestfile.t.js
Code that you think you will use again (in other tests) should be added to your preload.js file.

For example, write a function that finds the submit button on your page and clicks it. (You’ll probably need to click the submit button in many of your tests).

function clickOnButtonSubmit (t, callback) {

 // Searching for our Submit button
 var button = Ext.ComponentQuery.query('button[action=submit]');
  function (next) {
   // Clicking the button[0],callback);

Call the function in your test file.
StartTest(function(t) {

  function (next) {

Add the test file to index.js
var Harness = Siesta.Harness.Browser.ExtJS;
 title  : 'Awesome Test Suite',
 hostPageUrl : '../yourapp/index.html',
 preload  : [ 'preload.js' ]  // Path is relative to the location of the index.js file
 'Mytestfile.js', // Path is relative to the location of the index.js file

Open siesta UI and execute your test!