Sahi Pro Applet Support

abstract This section details how to test Java Applets. If you are not familiar with Sahi Pro, refer Quick Tutorial on Sahi Pro
warning Sahi Pro v7.0.0 has a newer mechanism of automating applets. The older implementation of applet automation has now been removed.

Pre-requisites

  1. You need Sahi Pro version v7.0.0 or above
  2. Sahi Pro Desktop Add-on needs to be installed.
  3. infoBoth Browser and Desktop capabilities should be enabled. (Needs both Sahi Pro and Sahi Pro Desktop Add-on licenses)
infoIf you are not familiar with Sahi Pro, refer Quick Tutorial on Sahi Pro

Recording an Applet

From the Sahi Dashboard, open the browser which supports applet and navigate to the page containing your applet.
Press ALT and double click on the document window of the page which you want to record. Sahi's Controller window will popup. You can now start recording. As with normal Sahi, you can use CTRL-Hover to identify various elements on the applet.

Use of JavaApplet Mode

  1. To use "Evaluate expression" on Java applets, choose "Sahi-JavaApplet".
  2. For script playback in Controller Playback tab, select Start Mode as "Browser" and enter "Start URL" before "Play".

Applet APIs

Applets APIs are different from normal JavaScript APIs. Most components are identified by its class name prefixed by "_jv".

Example:
_jvJButton("Test Button")
or
_jvJComboBox("ComboBox")


Applet also supports _near, _in and _under APIs.

Example:
_jvJComboBox("ComboBox", _near(_jvJLabel("Mouth")));

_highlight(_jvJComboBox("ComboBox", _under(_jvJLabel("Mouth"))));

_setSelected(_jvJComboBox("ComboBox", _near(_jvJLabel("Mouth"))), "Larry");

_click(_jvJButton("sun_small.gif"));


For applet automation, you need to use _setMode("JAVA_APPLET") at the start of the script.

Trouble Shooting

Page hangs or Sahi does not recognize any element

  1. While automating applets using Sahi make sure that java uses browser's proxy setting. This can be configured in Java Control Panel as shown in below images.
  2. Clear Java cache by deleting Temporary Files through the Java Control Panel. Click on the "Settings" button. Uncheck the checkbox adjacent to "Keep temporary files on my computer" and click "Delete Files.." then click "Ok" button.
  3. Click on the "Configure" link on the Sahi Dashboard and click "download_contenttypes.txt". Comment "application/octet-stream", save and restart Sahi.

Sample applet

A sample applet is available at http://sahi.co.in/demo/applet/simple.htm