Talk:PMC:QA:Research Sahi
From ADempiere
This Wiki is read-only for reference purposes to avoid broken links.
Contents
Original text from Sunny
This detail has been overtaken by updates to the Sahi software.
Start Sahi
now you can start Sahi in console
first time for start Sahi
workbox bin # ./sahi.sh -------- SAHI_HOME: .. SAHI_USERDATA_DIR: ../userdata SAHI_EXT_CLASS_PATH: -------- Sahi properties file = /mnt/sda4/Sahi/sahi/config/sahi.properties Sahi user properties file = /mnt/sda4/Sahi/sahi/userdata/config/userdata.properties Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi0 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi1 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi2 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi3 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi4 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi5 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi6 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi7 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi8 Copying profile to /mnt/sda4/Sahi/sahi/userdata/browser/ff/profiles/sahi9 >>>> 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
then you can access http://localhost:9999/ via your browser
you can see follow interface:
test Sahi
Configuring Firefox to use Sahi's proxy
install FoxyProxy plugin.you can see it in the lower right corner of Firefox
click it,then configurate it.
1.open FoxyProxy
2.add new Proxy
select ok.
3.use Sahi's proxy(localhost:9999)
close
after configuration, you can see we are using Sahi's proxy now
Sahi Controller
start Sahi,access http://localhost:9999 and put in start URL(eg.http://www.google.co.in/)
then will pop up Sahi Controller and open http://www.google.co.in/
Script Examples
common_functions.sah
//************************************************************** // A collection of common functions to use in // ADempiere sahi tests. // // Release: 3.6.0LTS //************************************************************* //login with given user and password, language english and default role, client //org and warehouse function login($usr, $pwd) { _assertExists(_textbox(0)); _setValue(_textbox(0), $usr); _assertExists(_password(0)); _setValue(_password(0), $pwd); _assertExists(_textbox(1)); _setValue(_textbox(1), "English"); _assertExists(_image("Ok24.png")); _assert(_isVisible(_image("Ok24.png"))); _click(_image("Ok24.png")); //use default role and org _assertExists(_image("Ok24.png")); _assert(_isVisible(_image("Ok24.png"))); _wait(2000); _click(_image("Ok24.png")); } //login using the given values function loginWithRole($usr, $pwd, $language, $role, $client, $org, $warehouse) { _assertExists(_textbox(0)); _setValue(_textbox(0), $usr); _assertExists(_password(0)); _setValue(_password(0), $pwd); _assertExists(_textbox(1)); _setValue(_textbox(1), $language); _assertExists(_image("Ok24.png")); _assert(_isVisible(_image("Ok24.png"))); _click(_image("Ok24.png")); _wait(2000); _assertExists(_textbox(0)); _setValue(_textbox(0), $role); _assertExists(_textbox(1)); _setValue(_textbox(1), $client); _assertExists(_textbox(2)); _setValue(_textbox(2), $org); _assertExists(_textbox(3)); _setValue(_textbox(3), $warehouse); _assertExists(_image("Ok24.png")); _assert(_isVisible(_image("Ok24.png"))); _click(_image("Ok24.png")); } function logout() { _assertExists(_link("Log Out")); _click(_link("Log Out")); }
Ref_6418.sah
_include("common_functions.sah"); var $orderno = null; function openOrderWindow($orderno) { _click(_div("Sales Order")); _click(_image("Find24.png")); if($orderno != null) { _assertExists(_textbox(/Field_DocumentNo/)); _setValue(_textbox(/Field_DocumentNo/), $orderno); } _click(_image("Ok24.png")); } function addChatMsg($msg) { _assertExists(_image("Chat24.png")); _click(_image("Chat24.png")); _assertExists(_textarea(1)); _setValue(_textarea(1), $msg); _assertExists(_image("Ok24.png")); _click(_image("Ok24.png")); } function checkChatEntryExists($entry) { _assertExists(_image("Chat24.png")); _click(_image("Chat24.png")); _assertExists(_div(/Chat/)); var $expression = "/.*"; $expression = $expression.concat($entry); $expression = $expression.concat("/"); _assertExists(_div($expression), _in(_div(/Chat/))); _assertExists(_image("Cancel24.png")); _click(_image("Cancel24.png")); } _navigateTo("http://asds2.adempiere.de:8080/webui/"); login("GardenAdmin", "GardenAdmin"); _wait(1000); openOrderWindow($orderno); _set($orderno, _textbox("/Field_DocumentNo/").value); addChatMsg("TEST"); checkChatEntryExists("TEST"); logout(); login("GardenUser", "GardenUser"); _wait(1000); openOrderWindow($orderno); checkChatEntryExists("TEST"); addChatMsg("OK"); logout();
Rev_6419.sah
_include("common_functions.sah"); //_navigateTo("http://asds2.adempiere.de:8080/webui/"); login("GardenUser","GardenUser"); _wait(1000); _assertExists(_div("System Admin")); _click(_div("System Admin")); _assertExists(_div("Organization Rules")); _click(_div("Organization Rules")); _assertExists(_div("Organization")); _click(_div("Organization")); _wait(1000); _assertExists(_span("Organization Info")); _click(_span("Organization Info")); _wait(1000); _assertExists(_span("CashBook for transfers")); _assert(_isVisible(_span("CashBook for transfers"))); _assertExists(_span("Bank for transfers")); _assert(_isVisible(_span("Bank for transfers"))); _assertExists(_span("Receipt Footer Msg")); _assert(_isVisible(_span("Receipt Footer Msg"))); logout();
common_functions.sah
/******************************************************************** * common_functions.sah * * A collection of common functions used in multiple scenarios. * * Requires the following variable declarations in the scenario * * var $server = "http://asds1.adempiere.de/webui/"; * var $release = "Release 3.6.0LTS"; * var $usr = "GardenAdmin"; * var $pwd = "GardenAdmin"; * var $client = "GardenWorld"; * var $org = "*"; * var $rememberMe = "No"; * *******************************************************************/ // Function declarations function verifyLogin($usr, $client, $org){ // Test the login id that appears in the top right corner of the browser var $zkLoginID = "zk_comp_109"; // The zk ID of the login id var $loginID; $loginID = $usr + "@" + $client + "." + $org; _assertExists(_span($loginID)); _assert(_isVisible(_span($loginID))); _assertEqual($loginID, _getText(_span($loginID))); //_assertContainsText($loginID, _span($loginID)); } function login($usr, $pwd, $org, $rememberMe){ // Used from the main login screen. Assumes default role // $rememberMe can be "Yes" or "No" _setValue(_textbox(0), $usr); _setValue(_password(0), $pwd); _assertExists(_checkbox(0)); _assert(_isVisible(_checkbox(0))); if ($rememberMe == "No") { if (_condition(_checkbox(0).checked)){ _click(_checkbox(0)); // Remember Me check box is selected. Deselect it. } } else { if ($rememberMe == "Yes") { if (_condition(_checkbox(0).checked)){ // No change required } else { _click(_checkbox(0)); // Remember Me check box is deselected. Select it. } } } _click(_image("Ok24.png")); //Login - Connection // TODO: Add sets/tests for Role and Org _click(_image("Ok24.png")); //Roles and Organization _wait(2000) // Wait for the page to load verifyLogin($usr, $client, $org); //check that the correct login occured } function versionTest($Version){ // Used on login screen to test the version number _assertExists(_cell($Version)); _assert(_isVisible(_cell($Version))); _assertEqual($Version, _getText(_cell($Version))); _assertContainsText($Version, _cell($Version)); } // End of common functions
tf_create_order.sah
// tf_sample_create_order.sah // // Tests that an order can be created, a line item added and the order saved. // Verifies that the grand total is correct. // function test_create_order(){ // Run from the main menu _click(_span("z-tree-ico z-tree-root-close[3]")); //Quote to invoice _click(_span("z-tree-ico z-tree-tee-close[18]")); //Sales Orders _click(_div("Sales Order")); _click(_link("New Record")); _setValue(_textbox(/^Field_AD_Org_ID/), "Fertilizer"); _setValue(_textbox(/^Field_C_DocTypeTarget/), "POS Order"); _setValue(_textbox(/^zk/,_in(_div(/^Field_C_BPartner_ID/))), "Joe Block"); _setValue(_textbox(/^Field_M_Warehouse_ID/), "Fertilizer"); _setValue(_textbox(/^Field_M_PriceList_ID/), "Standard"); _setValue(_textbox(/^Field_SalesRep_ID/), "GardenAdmin"); _click(_div("Save Changes")); _click(_submit("Order Line")); //Open the order line tab _click(_image(/^Product/, _in(_div(/^Field_M_Product_ID/)))); //Open the product window _click(_image("Refresh24.png[1]")); //Refresh the list of products _wait(1000); //Wait for the page to load _click(_div("Mary Consultant")); //Select Mary _click(_image("Ok24.png")); // Confirm _setValue(_textbox(/^Field_C_Tax_ID/), "Standard"); _click(_link("Save changes")); // Save _click(_submit("Order")); _assertEqual("90.00", _getValue(_textbox(/^z-decimalbox/, _in(_div(/^Field_GrandTotal/))))); _click(_link(/close$/, _in(_div("z_tabs_header")))); // Close the window _log("Test Completed", "info") // Test Completed. } // End of test_create_order
scenario_sample_create_order.sah
// Variable declarations //var $server = "http://asds1.adempiere.de/webui/"; var $server = "http://dev-pc/webui/"; var $release = "Release 3.6.0LTS"; var $usr = "GardenAdmin"; var $pwd = "GardenAdmin"; var $client = "GardenWorld"; var $org = "*"; var $rememberMe = "No"; // Includes - common functions _include("miscellaneous/common_functions.sah"); // Includes - test flows _include("miscellaneous/tf_sample_create_order.sah"); // Setup function setUp(){ _navigateTo($server); versionTest($release); login($usr, $pwd, $org, "No"); } // Tear down function tearDown() { _click(_link("Log Out")); } // Run the tests _runUnitTests(); _log("Test Completed", "info") // Test Completed. // End of test