Best practices for Scripting
Hi All,
Being new with TC scripting technologies (however long time programmer),
I’m trying to clarify the best practice to test web applications with JScripts.
Consequently I would like to compress the long-stretched script converted from KeyWord test into something handy using either:
- enumeration type variables as described by Gennadiy Alpaev in his book: ‘TestComplete Cookbook’ (Chapter 3 page 62)
- and/or functions to perform property checks and actions (saw one forum thread with: clickObject(propName, propValue, depthOfSearch)
Not sure if this is the best way to go(!), however I tried something like:
function funUiCheckPageLogin()
{
//declare page related variables:
panSplash = Aliases.browser.pageLogOn.panelSplashBackground;
var strObjReference = "";
var enuFrmSplashObj = ["textnodePleaseLogOn", "labelLeadlabel"];
var enuFrmSplashPrm = ["contentText", "contentText"];
var enuFrmSplashVal = ["Please log on", "Email/Username:"];
//Checks:
try
{
for(var i = 0; i < enuFrmSplashObj.length; i++)
{
//the below line will fail obviously for the object won't be built up with the enumeration string addition
var objObjReference = frmSplash.enuFrmSplashObj;
aqObject.CheckProperty(objObjReference, enuFrmSplashPrm, cmpEqual, enuFrmSplashVal);
}
}
Since I could not find best scripting practice techniques in otherwise exceptional SmartBear help pages and forums (still foraging through them...), I thought someone might share with me his/her tightly kept secrets regarding these techniques... :)
Cheers,
Lto
- Hi László, using a combination of JScript Constructors and the Test Complete Page Object, it is possible to approximate the Selenium Page Object pattern.
This provides the benefits of:
Single point of contact to Page elements, if an element on a page changes, only a single point in the code needs changing to reflect the change.
Abstracting Page and Element interaction away from Test Scripts, Test Scripts need only know how to use a Page Object, the detail of addressing a Page element is hidden away making simplifying Test Scripts.
Promotes re-usability
For mine, this is the minimum standard to adhere to when writing automated Test Scripts for Browser applications. In fact, I use similar patterns for testing Windows forms applications.
Regards,
Phil Baird