Forum Discussion

LOrban's avatar
LOrban
Occasional Contributor
11 years ago
Solved

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