EyeAutomate API

Using the EyeAutomate API from Java

Use the EyeAutomate API to create powerful test scripts or applications in Java. The API documentation can be found in the “javadoc” folder. Make sure to add the “EyeAutomate.jar” file to the project build path.

Java API Example:

public class TestExample
{
  public void RunTestExample()
  {
     ScriptRunner scriptRunner=new ScriptRunner(null);
     scriptRunner.runScript("Click", "Click \"images/button.png\"", null);
  }
}

Custom Commands

Extend the capabilities of EyeAutomate by creating new commands using Java.

EyeAutomate loads and launches Java classes dynamically. All commands are stored in the “custom” folder. Both the compiled Class file and the corresponding source code is provided.

Modify the source code or create your own and place the compiled Class into the “custom” folder. EyeStudio will load all the classes in the “custom” folder (and sub-folders) at startup.

Creating a Custom Command
A custom Java Class must contain the executeCommand method:

public Boolean executeCommand(String[] commandParameters, Properties scriptParameters)

A Java command that belongs to the “custom” package and placed in the “custom” folder will automatically appear in the list of available commands in EyeStudio.

Java libraries (jar files) located in the “custom” folder are automatically loaded by EyeAutomate at runtime.

A custom Java Class may contain a getHelp method that should return an HTTP address to context help for the command:

public String getHelp()
{
  return "http://eyeautomate.com/basiccommands.html";
}

Specify the parameters that the custom class might create or modify using the getParameters method. This will prevent EyeStudio from asking the value of the undefined parameter. This method should return a String array of parameters:

public String[] getParameters()
{
  return new String[]{"Error", "Response"};
}

The getCommand method can be used for requesting some information from the user before adding the command to the script. The getCommand method should return the text to be added to the script.

The tag “” will be replaced, by EyeStudio, with the path of a captured image:

public String getCommand()
{
  return "Move \"\"";
}

The tag “” will be replaced with a string:

public String getCommand()
{
  return COMMAND+" ...EndRepeat";
}

The string may have a default value:

public String getCommand()
{
  return COMMAND+" \"\"";
}

A string can include a number of options to select from:

public String getCommand()
{
  return COMMAND+" \"\"";
}

The setScriptRunner method can be used to receive a reference to the ScriptRunner currently used. Use the ScriptRunner to perform API methods.

public void setScriptRunner(ScriptRunner scriptRunner)
{
  this.scriptRunner=scriptRunner;
}

The getTooltip method can return a tooltip displayed in EyeStudio.

public String getTooltip()
{
  return "Adds all parameters";
}

Selenium Custom Commands

Selenium commands are stored in the “custom/selenium” folder and they are automatically loaded when EyeAutomate or EyeStudio starts.

A Selenium command is just like any other custom command. See the Custom Command section for instructions. Add or modify the classes, in the “custom/selenium” folder, and restart EyeAutomate when done.

A Selenium command may get and set the currently used web driver using the methods:

public void setWebDriver(WebDriver webDriver)
{
  this.webDriver=webDriver;
}

public WebDriver getWebDriver()
{
  return null;
}

Custom Command Examples
Study the commands in the “custom” folder. All EyeAutomate commands are provided with Java source code.