Skip to content
Get Free Trial

Java Controller

Sahi's Controller allows you to interact with Sahi and easily experiment and debug on the browser. This section explains using the Controller in Java mode, for writing scripts in Java instead of Sahi script (javascript)

Java Controller for Sahi Pro.

To identify an element, press the Ctrl (⌘ on Mac) key and hover over any element

Modes available in Sahi Pro for recording or identification:

  1. Browser: This mode is always enabled in Sahi Pro. Uncheck the checkbox for recording or identification in Browser mode only.

  2. Windows: Check the checkbox to enable recording or identification for Windows. Sahi Pro Desktop Engine should be installed for this.

  3. Java Applet: For recording or identification in Java Applet mode Sahi Pro Desktop Engine should be installed.

  4. Java Web Start: For recording or identification in Java Web Start mode Sahi Pro Desktop Engine should be installed.

  • Accessor: shows the Java accessor for that element
  • Alternatives: shows all alternative accessors for that element
  • Value/Text: shows the value of the current element. Mostly this is the input text or the visible text.
  • Prefix:Populates the prefix as needed when working with popup windows and multiple domains. Eg. on a popup window, this may be populated with _popup("New Window")
  • Mode: shows mode of application for which element is recording or identifying (not present in Sahi Pro).

These buttons perform various actions on the element and also show the generated script in the “Evaluate Expression” box. These are used to quickly work with elements during debugging/script generation.

  • Click clicks on the identified element. Invokes the .click() API.
  • Hilight highlights the identified element (shows a red 1 pixel border briefly). Invokes the .highlight() API.
  • Set sets the value in “Value:” field on the identified element. Invokes the .setValue("") API.
  • Hover does a mouse over on the element. Invokes the .mouseOver() API.
  • Assert assert the behaviour of the system is as expected or not.

Assertions are used to verify that the behaviour of the system is as expected. To add assertions using Sahi Java controller,

  1. Ctrl-hover (⌘-hover on Mac) on the element to identify it and then click on Assert button
  2. A few possible assertions for that element will be populated in the Evaluate Expression box
  3. Select mode for evaluate application of which it identified
  4. Click on Append button to append the assertions to the script.

Evaluate Expression box is used to evaluate snippets of Sahi Java code. It helps while identifying elements or while debugging.

  • Set mode for evaluate Select appropriate application mode before evaluate the expression.
  • Test → Put a valid Sahi expression in the Evaluate Expression box and click on Test →. The result will be seen in the bottom box.
  • Append While recording, selecting and clicking on Append will append the steps to the currently recording script. This is mainly used for manually append any step from Evaluate Expression to the currently recording script.
  • Highlight Can be used on selected text to highlights the element (shows a red 1 pixel border briefly). Invokes the .highlight API.
  • Click Can be used on selected text to click the element. Invokes the .click API.
  1. Choose the type of application for recording or identification.

  2. Click on ‘Record’ button and perform desired actions on the web page.

  3. Click on ‘Stop’ button to stop recording.

  4. Then click on ‘Recorded Steps’ button and it will show all the recorded steps.

  5. ‘Clear’ button is used to clear all the recorded steps.