Sahi Pro - Sahi Applet Support (Beta)
Introduction
Sahi Pro V4.5 and higher versions provide support for automation of applets.
For automating your applets you need to configure Sahi for applet support.
- Open
/config/sahi.properties
- Set the below statement to true and save this file
applet_support.enabled=true
- Open
/userdata/config/substitutions.xml
- Add rule as given below.
- Save this file.
- Restart Sahi.
When applet is bundled in a jar
<rule>
<name>change_user_jars</name>
<urlPattern>.*</urlPattern>
<isRegExp>false</isRegExp>
<find><![CDATA[user_jar.jar]]></find>
<replace><![CDATA[user_jar.jar,sahiapplet.jar]]></replace>
</rule>
Replace user_jar.jar with the jar that your applet uses.When applet is NOT bundled in a jar, using applet tag
In case your applet does not use a jar and you are using<applet>
tag for inserting your applet in HTML page. Use<rule>
<name>change_user_jars</name>
<urlPattern>.*</urlPattern>
<isRegExp>false</isRegExp>
<find><![CDATA[<applet]]</find>
<replace><![CDATA[<applet archive='sahiapplet.jar']]></replace>
</rule>
In your HTML file, if your <applet
tag is in upper case, use <APPLET
instead of <applet
above (in both find and replace nodes).When applet is NOT bundled in a jar, using object tag
In case your applet does not use a jar and you are using<object>
tag for inserting your applet in HTML page. Use<rule>
<name>change_user_jars</name>
<urlPattern>.*</urlPattern>
<isRegExp>false</isRegExp>
<find><![CDATA[</object>]]</find>
<replace><![CDATA[<param name='archive' value='sahiapplet.jar'/></object>]]></replace>
</rule>
In your HTML file, if your </object>
is in upper case, use </OBJECT>
instead of </object>
above (in both 'find' and 'replace' nodes).Automating Oracle Forms
For automating Oracle Forms following steps need to be done
- Open "Configure Sahi" page by clicking on "configure" link on Sahi's Dashboard.
- Click on “download_contenttypes.txt”.
- Remove the following line from download_contenttypes.txt.
- Click Save.
- Restart Sahi.
application/octet-stream
Recording an Applet
From the Sahi Dashboard, open any browser 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 (outside applet area). 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.
NOTE: Sahi currently automates only Java Swing based applets
Applet APIs
Applets APIs are different from the normal JavaScript APIs. All elements are prefixed with
_a("appletId").
or _applet("appletId").
followed by the component type and component id.
Example:_a("SampleApplet").jbutton("Test Button")
or_applet("SampleApplet").jbutton("Test Button")
_a and _applet API's can be used interchangebly.Applet also supports near
, inside
and under
APIs.
_a("SampleApplet").jcombobox("").near(_a("SampleApplet").jlabel("Mouth"));
_highlight(_a("SampleApplet").jcombobox("").under(_a("SampleApplet").jlabel("Mouth")));
_setSelected(_a("SwingSet2Applet").jcombobox(3).near(_a("SampleApplet").jlabel("Mouth")),"Larry");
_click(_a("SwingSet2Applet").jbutton("sun_small.gif"));
Some more detail on Applet APIs
Trouble Shooting
Java security error while loading applets with Sahi
Following security error may occur while automating applets with Sahi.Solution
- Open Java Control Panel. Where is Java Control Panel in Windows
- Select "Enable - hide warning and run with protections" Security verification option as shown in below image.
Where is Java Control Panel in Mac
Page hangs or Sahi does not recognize any element
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.