PMC:QA:Research Sahi:Sample Script - Login Remember Me

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

This sample is the contents of a single .sah file to test the "Remember Me" functionality of the login screen. Cut and paste to a .sah file on your system and give it a try.

//**************************************************************
// Simple test of the Remember Me functionality
// Set the $rememberMe variable accordingly
// Test:
//   Log on
//   Create a sales order
//   Add a BPartner
//   Cancel the order
//   Log out
//   Test to see if the log in values are remembered or not.
//
// Starting page: any as long as you are not logged in 
//*************************************************************

// Variable declarations

var $server = "http://adqa.adempiereqa.com/webui/";
var $release = "Release 3.6.0LTS";
var $usr = "GardenAdmin";
var $pwd = "GardenAdmin";
var $client = "GardenWorld";
var $org = "*";
var $rememberMe = "No";  //Yes or No


// Function declarations

function login($usr, $pwd){
	// Used from the main login screen
	_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
}

function testVersion($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));
}

function verifyLogin($usr, $client, $org){
	// Test the login id that appears in the top right corner of the browser
	var $loginID;
	$loginID = $usr + "@" + $client + "." + $org;

	//var $zkLoginID = "zk_comp_109"; // The zk ID of the login id
	var $zkLoginID = $loginID; // The login string

	__assertExists(_span($zkLoginID));
	__assert(_isVisible(_span($zkLoginID)));
	__assertEqual($loginID, _getText(_span($zkLoginID)));
	//_assertContainsText($loginID, _span($zkLoginID));
}	


// Start test	

_navigateTo($server);
//_click(_link("ADempiere ZK webUI")); // If starting from the server monitor page.

testVersion($release);
login($usr, $pwd);

_wait(2000); //Wait for the page to load

_click(_link("Sales Order")); // Open the sales order window

_wait(1000); //Wait for the page to load

_click(_image("New24.png")); // Create a new sales order

_click(_link("&New Record")); //Create a new BPartner

// Fill in the BPartner
_setValue(_textbox(51), "MI5");
_setValue(_textbox(53), "Molly Penney");
_setValue(_textbox(54), "Admin Asst");

// Fill in the location
_click(_image("Location10.png"));
_setValue(_textbox(50), "#10 Downing");
_setValue(_textbox(54), "London");
_setSelected(_select(1), "United Kingdom");
_click(_image("Ok16.png")); // Save the location

_click(_image("Ok24.png")); // Save the BPartner

_click(_image("Save24.png"));  // Try to save the page

_click(_image("Ignore24.png")); // Cancel the entry

_click(_link(4)); // Close the sales order window

verifyLogin($usr, $client, $org);

_assertExists(_link("Log Out"));
_click(_link("Log Out"));

// Back on the login screen
_assertExists(_textbox(0));
_assert(_isVisible(_textbox(0)));

if ($rememberMe == "No"){
	_assertNotEqual($usr, _getValue(_textbox(0)),"User ID Remembered! Should be blank.");
} else {
	if ($rememberMe == "Yes"){
		_assertEqual($usr, _getValue(_textbox(0)), "User ID not remembered!");
	}
}

_log("Test Completed", "info") // Test Completed.

// End of test