PMC:QA:How to create your first Sahi test in Adempiere Webui

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

How to create your first Sahi test in Adempiere Webui

Sahi is an automation and testing tool for web applications, with the facility to record and playback scripts. Sahi runs on any modern browser which supports javascript.

Download Sahi from: http://sourceforge.net/projects/sahi/files/ ,extract the package,next you can start it.

Start Sahi

create sahi test,first you need to start sahi server.

  • Windows:
    • Go to <sahi_root>\bin and run sahi.bat or
    • go to <sahi_root>\userdata\bin and run start_sahi.bat
  • Linux:
    • Go to <sahi_root>/bin and run sahi.sh or
    • go to <sahi_root>/userdata/bin and run start_sahi.sh

Example:

bin # ./sahi.sh
--------
SAHI_HOME: ..
SAHI_USERDATA_DIR: ../userdata
SAHI_EXT_CLASS_PATH:
--------
Sahi properties file = /root/.hudson/jobs/Sahi/workspace/sahi/config/sahi.properties
Sahi user properties file = /root/.hudson/jobs/Sahi/workspace/sahi/userdata/config/userdata.properties
>>>> Sahi started. Listening on port: 9999
>>>> Configure your browser to use this server and port as its proxy
>>>> Browse any page and CTRL-ALT-DblClick on the page to bring up the Sahi Controller

Note that by default Sahi uses port 9999. This can be modified through sahi.properties

Configure the browser

You need to change your browser’s proxy setting to use Sahi’s proxy.

Example:

browser:chromium

Options -> NetWork,click "Change proxy Settings",select "Manually specify the proxy settings" and set it by click "Setup"

  • Set “HTTP Proxy” to “localhost”
  • Set “Port” to “9999”. (This setting can be modified through /config/sahi.properties).

Recording through Sahi

  • Press CTRL and ALT keys together and then double click on the window which you want to record. Sahi’s Controller window will pop up.
  • On the Controller, go the the Record tab
  • Give a name for the script, and click ‘Record’
  • Navigate on your website like you normally would. Most actions on the page will now get recorded.

Note:If want to test adempiere webui,the new address is http://adqa.adempiereqa.com/ Example:

Sahitest.png

  • Add an assertion:
    • Move the mouse over any html element while pressing Ctrl key. The Accessor field will get populated in the Controller.
    • Click the “Assert” button to generate assertions for the element. They will appear in the “Evaluate Expression” box.
    • Click “Test —>” to check that the assertions are true.
    • Once satisfied, click on “Append to Script”. This will add the assertions to the Script.

Example:

Sahitest1.png

    • Click “Stop” to finish recording.

View the recorded script

The recoded script can be viewed and edited by opening the .sah file in the <sahi_root>\userdata\scripts directory

Example:

scripts # pwd
/root/.hudson/jobs/Sahi/workspace/sahi/userdata/scripts
sunny scripts # cat login.sah
_setValue(_textbox(0), "SuperUser");
_setValue(_password(0), "System");
_click(_image("spacer.gif"));
_assertExists(_image("Ok24.png"));
_assert(_isVisible(_image("Ok24.png")));
_click(_image("Ok24.png"));
_click(_image("spacer.gif"));
_click(_cell("GardenWorld Admin"));
_click(_image("Ok24.png"));

Playing back

  • go the palyback tab
  • Enter the script name in the “File:”
  • Enter the Start URL of the test.
  • Click ‘Set’.
  • Wait for the page to reload.
  • Click ‘Play’.

Example:

Sahitest2.png

Steps will start executing, and the Controller will be updated accordingly. Once finished, SUCCESS or FAILURE will be displayed at the end of the steps.

Sahitest3.png

View Logs

On the Controller, go to Playback tab and click on “View Logs” link at the bottom right. It will open a window with the results neatly formatted in HTML.

Clicking on a line in the logs will drill down to exact line in script.

Sahitest4.png

Sahitest5.png

You can also view the logs at http://localhost:9999/logs

That is it! You have successfully recorded and played back a Sahi script!

Reference

Links

   * Go back to PMC:QA