Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ with your query.

Shall we record the new script when technology changes?

Pratik_ShahPratik_Shah Moderators
edited September 5 in Sahi Pro
This is the question we keep getting in our support calls. How to design your scripts/suite if you change the technology? How to create the framework which should work for such changes? Be it changing it from Salesforce to Lightning or Angular to Angular 2.

Here is the answer to all such questions.

There are following types of changes that can happen over the application.

  • 1. Application UI has changed
  • 2. Application flow has changed.

We will take an example of Salesforce and Lightning to explain the framework. This deals with both the changes that can happen.

- We recorded scripts on a classic version with Accessor Repository Enabled and created a scenario file. (salesForcePoC.s.csv, classic_AR.sah)

The scenario file will remain the same as in both the application we need to first login and create the campaign. You will not need to modify the scenario file.

- Refactored the recorded script into functions. (functionsLib.sah). This is the common function file where we are keeping the functions for Salesforce.
function login($username, $pw){
	_setValue($_EMAILBOX_USERNAME, $username);
	_maskLogs("Masking the password");
	_setValue($_PASSWORD_PW, $pw);
	_unmaskLogs("Password masking ends");

function navigateCampaignMenu(){
        // Navigate to the campaign menu in Classic Version
	_wait(60000, _isVisible(_link("/Campaigns/")));

function createCampaign($campaignname, $startdate,$endDate, $expectedrevenue, $budgetedcost, $actualcost, $description){
	_wait(60000, _isVisible(_image(0)));
	_set($isLightning , document.domain.indexOf("lightning") >-1 );
                // There is slight change in the navigation for lightning version if the script is executed on lightning version, we are loading 
                 the files for lightning.
		_log("Lightning version detected, loading files for lightning.","CUSTOM2");		
       // If the script is executed on lightning version, navigateCampaingMenu() will be called of lightning_lib.sah 

	_setValue($_TEXTBOX_CAMPAIGNNAME, $campaignname);
	_setValue($_TEXTBOX_STARTDATE, $startdate);
	_setValue($_TEXTBOX_ENDDATE, $endDate);
	_setValue($_TEXTBOX_EXPECTEDREVENUE, $expectedrevenue);
	_setValue($_TEXTBOX_BUDGETEDCOST, $budgetedcost);
	_setValue($_TEXTBOX_ACTUALCOST, $actualcost);
	_setValue($_TEXTAREA_TEXTAREA, $description);

- Once the flow was recorded correctly, we tried to playback the same script on a lightning version.
- There is slight change in the flow and some of the UI elements, so created new functions for different flows (change in flow to reach to create a campaign in lightning version) and kept in (lightning_Lib.sah).

function navigateCampaignMenu(){
        // To handle the change in the flow. For classic, you need only 3 steps, for lightning steps and UI element has changed.
	_click( $_DIV_SLDS );
	_click( $_SPAN_CAMPAIGNS);

- Along with the flow, there were some changes in the element identifier. So added the new element identifiers (lightning_AR.sah)

var $_SPAN_CAMPAIGNS = _span("Campaigns");
var $_LINK_CAMPAIGNSMENU = _link("Campaigns Menu");
var $_DIV_NEW = _div("New");
var $_TEXTAREA_TEXTAREA = _textarea(" textarea");
var $_SAVE_BUTTON = _span("Save");
var $_DIV_SALES = _div("Sales");
var $_DIV_SLDS = _div("slds-r4");

var $_EMAILBOX_USERNAME = _emailbox("username");
var $_PASSWORD_PW = _password("pw");
var $_SUBMIT_LOGIN = _submit("Log In");
var $_TEXTBOX_CAMPAIGNNAME = _textbox("/Campaign Name/");
var $_TEXTBOX_STARTDATE = _textbox("Start Date");
var $_TEXTBOX_ENDDATE = _textbox("End Date");
var $_TEXTBOX_EXPECTEDREVENUE = _textbox("/Expected Revenue/");
var $_TEXTBOX_BUDGETEDCOST = _textbox("/Budgeted Cost/");
var $_TEXTBOX_ACTUALCOST = _textbox("/Actual Cost/");
var $_LABEL_DESCRIPTION = _label("Description");
var $_TEXTAREA_TEXTAREA = _textarea(0, _near($_LABEL_DESCRIPTION));
var $_SAVE_BUTTON = _submit("/Save/");
var $_LINK_LEADS = _link("Leads");
var $_BUTTON_NEW = _button(" New ");
var $_SELECT_NAME_SALUTATIONLEA2 = _select("name_salutationlea2");
var $_TEXTBOX_NAME_FIRSTLEA2 = _textbox("name_firstlea2");
var $_TEXTBOX_NAME_LASTLEA2 = _textbox("name_lastlea2");
var $_TEXTBOX_LEA3 = _textbox("lea3");
var $_TEXTBOX_LEA4 = _textbox("lea4");
var $_IMAGE_CAMPAIGNLOOKUP_NEWWINDOW = _image("Campaign Lookup (New Window)");
var $_LINK_TYTO = _link("Tyto");
var $_TEXTBOX_LEA20 = _textbox("lea20");
var $_SPAN_PRATIKSHAH = _span("Pratik Shah");
var $_LINK_LOGOUT = _link("Logout");
var $_LINK_CAMPAIGNS = _link("Campaigns");
var $_SPAN_CREATE_NEW = _span("Create New...");
var $_LINK_CAMPAIGN = _link("Campaign");

This is how it looks when we execute the same script on both the versions.

Create Campaign flow change

The conclusion:

- Record the script
- Create functions
- Call those functions in Scenario files
- Keep all the UI elements in the Accessor Repository Files.

So in future if there is any change in the flow, you just need to update the function file, if UI element has changed, you just need to update the Accessor Repository file.

You can read more about the best practices at

Let me know your comments.

Pratik Shah
Sign In or Register to comment.