Running a Script

Click the Run button, or select that option from the Script menu, to run the script. The output will be displayed in the log window below the script. You may also run a portion of the script. Select a number of commands and press the Run Selection button to run the selected commands.

Manual Run

A script can be run manually. All commands or steps are then displayed as manual instructions. Click the Manual Run button in the toolbar or select the Manual Run option from the Script menu to run a script manually.

Running a Suite of Scripts

A script may call other scripts. You may create a script, or suite, that only calls other scripts. The suite would only contain a number of Call commands.

The Call command may contain parameters to the script to execute. You may also specify a number of times to repeat the script before completing. For details, see the Call command in List of Commands.

Set StopIfFailed to No to prevent a suite from stopping if any of the called tests fails.

A called script will inherit all the parameters and settings, except StopIfFailed, from the calling script.

Test Suite Example:

Iterations

Blocks can be repeated. Use the Repeat command and specify the number of times to repeat. You may also iterate through all rows in a data file like in the example below:

The Iteration parameter will be set to the current iteration starting with 1.

Calling a Script with Parameters

Pass parameters to a script to make the script more reusable. Keys and values are separated with an “=” sign and parameters are separated by an “&” character. Provide a list of parameters before or after the script, for example:

Call “scripts/script1.txt” “sensitivity=90” “wait=1000”

Call “scripts/script1.txt” “sensitivity=90&wait=1000”

Call “sensitivity=90&wait=1000” “scripts/script1.txt”

Parameters may also be stored in a data (CSV) file, like in the example call below:

Parameters may also be retrieved from a database using a Select statement. Note that the parameters: DatabaseDriverJar, DatabaseDriverClass and DatabaseConnection needs to be set before the call.

Parameters used when connecting to the database:

Parameter

Description

Default value

DatabaseDriverJar

Path and name of the jar file that contains the JDBC driver.

mysql-connector-java-5.1.23-bin.jar

DatabaseDriverClass

The Class name of the database driver.

com.mysql.jdbc.Driver

DatabaseConnection

The database connection string.

jdbc:mysql://localhost/sakila?user=root&password=password

 

Example of a call with parameters from a database table:

Set DatabaseDriverJar "mysql-connector-java-5.1.23-bin.jar"
Set DatabaseDriverClass "com.mysql.jdbc.Driver"
Set DatabaseConnection "jdbc:mysql://localhost/sakila?user=root&password=password"
Call "select first_name, last_name from actor;" "scripts/hello.txt"

or by using Repeat:

Repeat "select first_name, last_name from actor;"
   Write "{first_name} {last_name}"
EndRepeat

Running Scripts from a Batch File

You may execute one or many scripts using the “EyeAutomate.jar” file. Place the calls in a batch file to be able to execute EyeAutomate several times in order to complete an entire test suite. Use, for example, the operating system command below to run a test:

java -jar EyeAutomate.jar scripts\script.txt

Run a script stored in a bundle
The bundle will be exacted to the root folder before the run.

java -jar EyeAutomate.jar scripts\bundle.eye

Run several scripts at a time

java -jar EyeAutomate.jar “scripts/script 1.txt” “scripts/script 2.txt”

Repeat one or many scripts several times

java -jar EyeAutomate.jar 10 scripts/script1.txt scripts/script2.txt

Run with a list of parameters

java -jar EyeAutomate.jar “sensitivity=90&wait=1000” scripts/script1.txt

Run with a data file
The script will be run for each row of data in the CSV file:

java -jar EyeAutomate.jar “scripts/parameters.csv” “scripts/script.txt”

Generating Reports from a Batch File

Create or update the Test Summary and Test Step Duration reports after a script has been executed using the -r command line option:

java -jar EyeAutomate.jar -r scripts\script.txt

Running Scripts from FitNesse

You may export scripts to FitNesse and run the scripts there. FitNesse is an open source tool for acceptance testing and can be downloaded from: www.fitnesse.org

Follow the steps below to run a test in FitNesse:

  • Use the Export as FitNesse option from the File menu to save a script as a FitNesse test.
  • The “EyeAutomate.jar” file needs to be copied to the same folder as the “fitnesse.jar” file.
  • Copy the “images” folder to the same folder as the “fitnesse.jar” file to make it possible for EyeAutomate to find them.
  • Copy the exported FitNesse test into a FitNesse page and run the test.

FitNesse Test Example:

!path EyeAutomate.jar
!define TEST_SYSTEM {slim}
!|script|eyeautomate.EyeAutomateFixture|
|execute|StartWeb www.eyeautomate.com|
|execute|WaitMouseMove images/1305050944885.png|
|execute|MouseLeftClick|
|execute|WaitMouseMove images/1305050956684.png|
|execute|MouseLeftClick|
|execute|WaitMouseMove images/1305050967915.png|
|execute|MouseLeftClick|
|execute|WaitMouseMove images/1305050976639.png|
|execute|MouseLeftClick|
|execute|WaitMouseMove images/1305050992470.png|
|execute|MouseLeftClick|
|execute|WaitMouseMove images/1305051550296.png|
|execute|MouseLeftClick|
|execute|WaitVerify images/1305053760123.png|

Running Scripts from Microsoft Visual Studio

EyeAutomate scripts can be run from within Microsoft Visual Studio. The example code below shows how to run and retrieve the output from a EyeAutomate script. Note that the EyeServer needs to be running on the machine (in this case localhost).

public void CallEyeAutomateTest()
{
  var response = RunEyeAutomateTest("MyTest.txt");
  Assert.IsTrue(response.StartsWith("Completed"));
}

public static string RunEyeAutomateTest(string script)
{
   var response = String.Empty;
   var request = String.Format(@"http://localhost:1234/scripts/{0}", script);
   var webClient = new WebClient();
   var stream = webClient.OpenRead(request);
   if(stream != null)
  {
   TextReader reader = new StreamReader(stream);
   response = reader.ReadToEnd();
  }
 return response;
}

Running Scripts from JUnit

EyeAutomate scripts can be run from within a JUnit test. This is convenient when running EyeAutomate scripts in a continuous integration server like Jenkins or CruiseControl. The example code below shows how to run a script from a JUnit test and using the ScriptLoggerTest class as the script logger. The “EyeAutomate.jar” file should be added to the Java Build Path.

import org.junit.Test;
import eyeautomate.ScriptRunner;
import eyeautomate.ScriptLoggerTest;
import eyeautomate.DerivativesCache;

public class ScriptRunnerTest
{
  @Test
  public void test()
  {
    ScriptRunner scriptRunner = new ScriptRunner(new ScriptLoggerTest());
    scriptRunner.setParameter("ImageFolder", "C:/EyeAutomate/images");
    scriptRunner.runScript("C:/EyeAutomate/scripts/myscript.txt");
  }
}

Creating Python Scripts

The Eye can be used in Python scripts by importing the “eye.py” library. Download the Python library from the EyeStore.

You need to start the EyeServer and have a valid license. Edit the “eye.py” file if you using anything else than localhost and port 1234.

The example below uses the “eye.py” library:

import eye

# Find all notepads
locations=eye.findImages('images/notepad.png')
if locations!='Image not found':
          for location in locations:
             print 'Found at: '+location[0]+', '+location[1]

             # Click and type 'Hello'
             eye.click(location[0], location[1])
             eye.type("Hello")
else:
          print 'Image not found'

The example below uses Selenium WebDriver:

import eye

# Open Wikipedia
eye.openBrowser('chrome', 'http://www.wikipedia.org')

# Find the search field
location=eye.findImage('images/search.png')
if location!='Image not found':
        # Click in the search field and type 'tiger' followed by ENTER
        eye.click(location[0], location[1])
        eye.type("tiger[ENTER]")

        # Find the tiger image
        locations=eye.findImages('images/tiger.png')
        if locations!='Image not found':
             for location in locations:
                     print 'Found at: '+location[0]+', '+location[1]
        else:

            print 'Image not found'

# Close the browser                
eye.closeBrowser()

Run Options

Run options can be found in the Settings/Run Options menu in EyeStudio.

Animate Cursor

Animate the cursor for mouse moves. Set this setting to No to improve script run speed.

Create Test Run Report

Create a Test Run Report directly after script run.

Hide Studio During Run

Hide EyeStudio while running a script.

Launch Test Run Report

Launch the Test Run Report directly after script run.

Lock Screen

EyeAutomate has a built-in screen lock to prevent unauthorized people from using the computer after a script has been completed or failed. Enter a password that contains digits only. At least 4 digits must be provided. Enter the password using the keyboard to unlock the lock screen.

Manual Recovery

Use manual recovery information when a step fails during the run.

Run Dialog On Top

Check to keep the Run Dialog on top of other windows making it easier to stop the run.

Save Before Run

Save any unsaved scripts before a run without asking.

Logs

Logs are stored in the “logs” folder in text or CSV format.

Execution Log
All executed commands are logged in the “execution_log.txt” file. You may also see the results of any of the Verify commands. A script will terminate with an error message in the execution log if any operation fails.

Test Log
All scripts are logged in the “test_log.txt” file. The log contains date and time when scripts started, completed or failed.

Run Statistics
Statistics from the script runs are stored in the “test_history.csv” and “test_steps.csv” files. EyeStudio stores test statistics from all test runs in the CSV files.