Sunday, December 1, 2013

Running Siesta from a remote computer

How to run Siesta from a remote computer using Selenium Webdriver:

Suppose you have a machine which has linux file system and you write your test on it; But the test you execute need to run on a windows machine (for all browsers support, or from any other reason). 
Now you want to run a command in your linux machine, that will execute remotely all the desired tests on the windows machine and send back to the linux the alerts regarding which test passed and which tests failed.

On the "Server"

  1. On the “server” – where you want to run the browser (aka - the windows machine) copy the siesta files and folders (the latest version which you can get from here: ) to c:\program files\
  2.  Install java (if not installed) from:
  3. Access the siesta directory from cmd, and run the following commands:
        # cd c:\Program Files\siesta-2.0.4-standard\bin
        # webdriver-server -port 4444

On the "Client"

On the "client" - (in this example, it's the linux machine) navigate to Siesta's installation folder (the webapp directory) and cd to webapp/bin.

From the bin directory, execute the command:

# webdriver [the URL of your siesta GUI] --host ["server" - windows host name or IP address] --port 4444 --browser=[which browser to run on the windows client, i.e: firefox, chrome, ie, safari ]

Additional Flags

If you want to run just one test you can use the “--include” flag. If you want the output to be in JUnit format  you can use the “--report-format” and “--report-file” flags. 

For Example:

# webdriver http://IP/siestaTests --include=MytestFile.t.js --host YourHostName --port 4444 --browser=ie --report-format=JUnit --report-file=MytestFile_log_

For IE

This configuration works fine on firefox and chrome, but for IE there is some adjustments to make:
  1. Download the driver from here:
  2. Copy to the windows machine (to C:\installations\selenium-2.37.0).
  3. Add this location in the PATH environment variables on your windows machine.
  4.  Set the protector mode: open the IE browser, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone (4 zones usually), there will be a check box at the bottom of the tab labeled "Enable Protected Mode" – all of them should be the same, all checked or all unchecked.
  5. Set the browser to IE9 mode (press F12 and change the browser mode), and place it on top of all other windows. 

In order to make IE run in standard mode, add this line to the index.html file in webapp directory, right after the <head> tag:

Good luck!

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!