Classes in Javascript
I can't tell what version of Javascript is currently supported by TestComplete, but I am really hoping it supports classes of somekind. (Bascially EcmaScript 2015)
I tried searching for it, but all the hits I found were 5+ years old. I am hoping things have improved in the last 5 years. (But I have tried playing around with it, and I can't seem to make it work.)
Here is an ES2105 style Javascript class I would like to be able to use:
export class CoolStuff{ constructor(){ this.coolness="this is cool"; } function runCoolness(addedCoolness){ Log.Message("Executing Coolness: " + this.coolness + " along with: " + addedCoolness); // Other Stuff here } } // In another file... let coolStuff = new CoolStuff(); coolStuff.runCoolness("more and more cool");
Is there a way to pull that kind of thing off with TestComplete?
From the help at https://support.smartbear.com/testcomplete/docs/general-info/version-history/features-added-to-ver-12-0.html
TestComplete 12 adds JavaScript (ECMAScript 6) as a new scripting language for writing automated tests. You can record, write, run, and debug tests written in JavaScript.
JavaScript in TestComplete is powered by the V8 engine – the same engine that is used in Google Chrome and Node.js. For the usage specifics, see JavaScript - Specifics of Usage.
As an example.... see, this past Friday was Hobbit Day (yes, I'm that much of a nerd) and I have this bit of PseudoCode hanging on my wall of my cubicle:
import gandalf; import balrog; import bridge_of_khazad-dum; public class GandalfvsBalrog extends Moria { Wizard Gandalf; //declare variables Balrog misterSparkles; main() { Gandalf.print("You Shall NOT PASS!!!); misterSparkles.print("RARARARRRRARR!!!!); Gandalf.HitGroundWithStaff_MakeBridgeFall; if(misterSparkles.isFallingWayDown) { misterSparkles.whipGandalf_bringHisButtDownToo; } while(Gandalf.isFallingWayDown) { Gandalf.GrabSword_KickButtandYellAlot; } return One_Smoted_Balrog; } }
So.... For Hobbit Day, I converted this into a JavaScript automation. I've attached the code units as an example... the result looks like: