SlideShare a Scribd company logo
Test Complete Coding 
Quick guide to using jScript with Test Complete by SmartBear
Create an object/class 
function myLogFileObject() 
{ 
this.myPublicObjectArray = []; 
var myPrivateObjectArray = []; 
var myPrivateCounter = 0; 
this.readFunction=function(); 
return true; 
} 
} 
Why? 
Nice way to organize 
functions and variables 
that represent that object. 
How to use? 
var myObject 
myLogFileObject(); 
myObject.readFunction();
Write to a text file 
var objFSO = new ActiveXObject("Scripting.FileSystemObject"); 
var outFile = objFSO.CreateTextFile(FileNameIncludingPath, 
true,false); 
outFile.WriteLine("Write me to the file"); 
outFile.Close();
Read a file 
var file=fso.OpenTextFile 
(fileLocationAndNameGolden, 
FileReadOnly); 
while (!file.AtEndOfStream){ 
var line=file.ReadLine(); 
}
Try/catch/finally 
try{ 
} 
catch(e){ 
Log.Message(e.description 
); 
} 
Finally{ 
{
Copy a file 
aqFile.Copy 
(FromFullPathINcludingFileName,ToFullPathIncludingFileNa 
me, true)
Iterate through an array 
var myArray = []; 
for(var k=0; k < myArray.length; k++){ 
outFile.WriteLine(myArray[k]); 
}
Switch statement 
switch(){ 
case "": 
{ 
//do 
something 
} 
case2 "" 
{ 
//do 
something 
} 
default: 
{ 
//do 
something 
} 
}
Built in Parameters 
// Built in Parameters 
function ProcessCommandLine(config) { 
for (i = 1; i<= BuiltIn.ParamCount();i++){ 
ProcessCommandLineArgument(BuiltIn.ParamStr(i),config); 
} 
}
Test Complete aqString 
aqString.Replace 
aqString.Trim 
aqString.Find 
aqString.ToLower 
aqString.ChangeListItem 
aqString.GetListItem 
aqString.FindLast 
aqString.GetLength 
aqString.SubSting( 
aqString.GetListLength
Do loop 
do{ 
//some commands 
}while( something is true)
Delete /copy file 
aqFileSystem.DeleteFile(outPath + newFileName + ".xml"); 
aqFileSystem.CopyFile(from, to) 
aqFile.Copy(FromFullPathINcludingFileName,ToFullPathIncl 
udingFileName, true)
Throw error 
//Check that the object isn't null 
if (obj == null) throw "Null object passed to 
generateXMLFromObjectFields";
Push an item to an array 
myArray = []; 
myArray.push(item);
Project variables 
// access test complete project variables 
var MyAppPath=Project.Variables.MyAppPath;
prototype 
//prototype 
var Dog=function(name) { 
this.name = name; 
var barkCount = 0; 
this.bark = function() { 
barkCount++; 
Log.Message(this.name + " 
bark"); 
}; 
this.getBarkCount = function() 
{ 
Log.Message(this.name + " 
has barked " + barkCount + " 
times"); 
};
prototype 
this.wagTail2= function() { 
Log.Message(this.name + " 
wagging tail2"); 
} 
}; 
Dog.prototype.wagTail = function() 
{ 
Log.Message(this.name + " 
wagging tail"); 
}; 
function dog_test(){ 
var dog = new Dog("Dave"); 
dog.bark(); 
dog.bark(); 
dog.getBarkCount(); 
dog.wagTail2(); 
dog.wagTail(); 
}
Extend Array - unique 
//Extend Array to return unique numbers only 
Array.prototype.unique = function() 
{ 
var tmp = {}, out = []; 
for(var i = 0, n = this.length; i < n; ++i) 
{ 
if(!tmp[this[i]]) { tmp[this[i]] = true; out.push(this[i]); } 
} 
return out; 
}
Read xml 
objXMLDoc = 
Sys.OleObject("Msxml2.DOMDocument.6.0") 
objXMLDoc.async = false ; 
objXMLDoc.setProperty("SelectionLanguage","XPath"); 
result=objXMLDoc.load(xmlConfigFile); 
xmlNode=xmlTestConfig.selectSingleNode("TestClass");
Read DOM 6.0 xml 
var objXMLDoc = 
Sys.OleObject("Msxml2.DOMDocument.6.0"); 
objXMLDoc.async = false; 
objXMLDoc.setProperty("SelectionLanguage","XPath"); 
var ns= "xmlns:a='http://smpte-ra. 
org/schemas/2021/2008/BXF'"; 
objXMLDoc.setProperty("SelectionNamespaces", ns); 
ar AsRunList=objXMLDoc.SelectNodes("//a:AsRun");
File functions 
var fso = Sys.OleObject("Scripting.FileSystemObject"); 
var file = fso.GetFile(file_path); 
var fol = fso.GetFolder(folder_path); 
fol.size 
var filesCount = fol.files.Count;
Generate XML from object 
var docSection = Storages.XML(""); 
var colFields = aqObject.GetFields(obj, false); 
var sec = docSection.GetSubSection(root_name);
Connect to UDP 
socket = dotNET.System_Net_Sockets.Socket.zctor( 
dotNET.System_Net_Sockets.AddressFamily.InterNetwork 
, 
dotNET.System_Net_Sockets.SocketType.Dgram, 
dotNET.System_Net_Sockets.ProtocolType.Udp);
SQL Server DB 
Conn = new ActiveXObject("ADODB.Connection"); 
var constr= "Provider=SQLOLEDB.1;Data 
Source=SERVERN;Initial Catalog=cat1;User 
ID=sa;Password=myPassword"; 
Conn.Open(constr); 
var catalogue = new ActiveXObject('ADOX.Catalog'); 
rs = new ActiveXObject("ADODB.Recordset");
Literal Object 
Create a simple constructor that contains the fields for that 
object 
Function User(theParam1){ 
This.param1 = theParam1; 
} 
Extend that object using the Literal prototype feature 
User.prototype = { 
Constructor: User, 
Functoin1: function(theParam2){ …
Shorter if/then 
Variable = (condition) ? True-value : false_value
Object fields and methods 
Var FieldsCol = aqObject.GetFields(Obj); 
Iterate through the fields 
while ( FieldsCol.HasNext() ){ 
Log.Message( FieldsCol.Next().Name ); 
} 
Use this to get the methods: 
aqObject.GetMethods(Obj);

More Related Content

What's hot

Mutiny + quarkus
Mutiny + quarkusMutiny + quarkus
Mutiny + quarkus
Edgar Domingues
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
123abcda
 
Performance Analysis: The USE Method
Performance Analysis: The USE MethodPerformance Analysis: The USE Method
Performance Analysis: The USE Method
Brendan Gregg
 
Tdd and bdd
Tdd and bddTdd and bdd
Tdd and bdd
MohamedSubhiBouchi
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
Skills Matter
 
Performance testing : An Overview
Performance testing : An OverviewPerformance testing : An Overview
Performance testing : An Overview
sharadkjain
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
Behave
BehaveBehave
Regression testing
Regression testingRegression testing
Regression testing
Anamta Sayyed
 
Async ... Await – concurrency in java script
Async ... Await – concurrency in java scriptAsync ... Await – concurrency in java script
Async ... Await – concurrency in java script
Athman Gude
 
Introduction to Stream Processing
Introduction to Stream ProcessingIntroduction to Stream Processing
Introduction to Stream Processing
Guido Schmutz
 
Spark introduction and architecture
Spark introduction and architectureSpark introduction and architecture
Spark introduction and architecture
Sohil Jain
 
Load and performance testing
Load and performance testingLoad and performance testing
Load and performance testing
Qualitest
 
How To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | EdurekaHow To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | Edureka
Edureka!
 
Tests de performances d'une application Java EE
Tests de performances d'une application Java EETests de performances d'une application Java EE
Tests de performances d'une application Java EE
Antonio Gomes Rodrigues
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
Mohammad Faizan
 
Apache Spark Crash Course
Apache Spark Crash CourseApache Spark Crash Course
Apache Spark Crash Course
DataWorks Summit
 
scenario testing in software testing
 scenario testing in software testing scenario testing in software testing
scenario testing in software testing
durgaaarthi
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
SANG WON PARK
 
Parallelization of Structured Streaming Jobs Using Delta Lake
Parallelization of Structured Streaming Jobs Using Delta LakeParallelization of Structured Streaming Jobs Using Delta Lake
Parallelization of Structured Streaming Jobs Using Delta Lake
Databricks
 

What's hot (20)

Mutiny + quarkus
Mutiny + quarkusMutiny + quarkus
Mutiny + quarkus
 
Automation test framework with cucumber – BDD
Automation test framework with cucumber – BDDAutomation test framework with cucumber – BDD
Automation test framework with cucumber – BDD
 
Performance Analysis: The USE Method
Performance Analysis: The USE MethodPerformance Analysis: The USE Method
Performance Analysis: The USE Method
 
Tdd and bdd
Tdd and bddTdd and bdd
Tdd and bdd
 
Bdd Introduction
Bdd IntroductionBdd Introduction
Bdd Introduction
 
Performance testing : An Overview
Performance testing : An OverviewPerformance testing : An Overview
Performance testing : An Overview
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
Behave
BehaveBehave
Behave
 
Regression testing
Regression testingRegression testing
Regression testing
 
Async ... Await – concurrency in java script
Async ... Await – concurrency in java scriptAsync ... Await – concurrency in java script
Async ... Await – concurrency in java script
 
Introduction to Stream Processing
Introduction to Stream ProcessingIntroduction to Stream Processing
Introduction to Stream Processing
 
Spark introduction and architecture
Spark introduction and architectureSpark introduction and architecture
Spark introduction and architecture
 
Load and performance testing
Load and performance testingLoad and performance testing
Load and performance testing
 
How To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | EdurekaHow To Write A Test Case In Software Testing | Edureka
How To Write A Test Case In Software Testing | Edureka
 
Tests de performances d'une application Java EE
Tests de performances d'une application Java EETests de performances d'une application Java EE
Tests de performances d'une application Java EE
 
SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4  SOFTWARE TESTING UNIT-4
SOFTWARE TESTING UNIT-4
 
Apache Spark Crash Course
Apache Spark Crash CourseApache Spark Crash Course
Apache Spark Crash Course
 
scenario testing in software testing
 scenario testing in software testing scenario testing in software testing
scenario testing in software testing
 
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
Apache kafka 모니터링을 위한 Metrics 이해 및 최적화 방안
 
Parallelization of Structured Streaming Jobs Using Delta Lake
Parallelization of Structured Streaming Jobs Using Delta LakeParallelization of Structured Streaming Jobs Using Delta Lake
Parallelization of Structured Streaming Jobs Using Delta Lake
 

Viewers also liked

Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test Complete
Vartika Saxena
 
Test Complete
Test CompleteTest Complete
Test Complete
RomSoft SRL
 
Automation Testing with TestComplete
Automation Testing with TestCompleteAutomation Testing with TestComplete
Automation Testing with TestComplete
RomSoft SRL
 
Script Driven Testing using TestComplete
Script Driven Testing using TestCompleteScript Driven Testing using TestComplete
Script Driven Testing using TestComplete
srivinayak
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
binuiweb
 
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBearTestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
Software Testing Solution
 
Test complete, work done so far
Test complete, work done so farTest complete, work done so far
Test complete, work done so far
Leonel More, CSM, PMP, ITIL
 
Testing_with_TestComplete
Testing_with_TestCompleteTesting_with_TestComplete
Testing_with_TestComplete
Samanuru G Chakravarthy
 
Keyword Driven Testing using TestComplete
Keyword Driven Testing using TestCompleteKeyword Driven Testing using TestComplete
Keyword Driven Testing using TestComplete
srivinayak
 
TestComplete 7.50 New Features
TestComplete 7.50 New FeaturesTestComplete 7.50 New Features
TestComplete 7.50 New Features
Vlad Kuznetsov
 
social prez - mpcc - mholterhaus
social prez - mpcc - mholterhaussocial prez - mpcc - mholterhaus
social prez - mpcc - mholterhaus
mholterhaus
 
Web Service Testing using TestComplete
Web Service Testing using TestCompleteWeb Service Testing using TestComplete
Web Service Testing using TestComplete
srivinayak
 
Scrum master motivation role
Scrum master motivation roleScrum master motivation role
Scrum master motivation role
Viresh Doshi
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
PolarSeven Pty Ltd
 
Prioritization by value (DevOps, Scrum)
Prioritization by value (DevOps, Scrum)Prioritization by value (DevOps, Scrum)
Prioritization by value (DevOps, Scrum)
Tommy Quitt
 
Selenium bootcamp slides
Selenium bootcamp slides   Selenium bootcamp slides
Selenium bootcamp slides
seleniumbootcamp
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef Automate
PolarSeven Pty Ltd
 
DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
Juan Vicente Herrera Ruiz de Alejo
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdf
seleniumbootcamp
 
Foundation selenium java
Foundation selenium java Foundation selenium java
Foundation selenium java
seleniumbootcamp
 

Viewers also liked (20)

Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test Complete
 
Test Complete
Test CompleteTest Complete
Test Complete
 
Automation Testing with TestComplete
Automation Testing with TestCompleteAutomation Testing with TestComplete
Automation Testing with TestComplete
 
Script Driven Testing using TestComplete
Script Driven Testing using TestCompleteScript Driven Testing using TestComplete
Script Driven Testing using TestComplete
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
 
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBearTestComplete – A Sophisticated Automated Testing Tool by SmartBear
TestComplete – A Sophisticated Automated Testing Tool by SmartBear
 
Test complete, work done so far
Test complete, work done so farTest complete, work done so far
Test complete, work done so far
 
Testing_with_TestComplete
Testing_with_TestCompleteTesting_with_TestComplete
Testing_with_TestComplete
 
Keyword Driven Testing using TestComplete
Keyword Driven Testing using TestCompleteKeyword Driven Testing using TestComplete
Keyword Driven Testing using TestComplete
 
TestComplete 7.50 New Features
TestComplete 7.50 New FeaturesTestComplete 7.50 New Features
TestComplete 7.50 New Features
 
social prez - mpcc - mholterhaus
social prez - mpcc - mholterhaussocial prez - mpcc - mholterhaus
social prez - mpcc - mholterhaus
 
Web Service Testing using TestComplete
Web Service Testing using TestCompleteWeb Service Testing using TestComplete
Web Service Testing using TestComplete
 
Scrum master motivation role
Scrum master motivation roleScrum master motivation role
Scrum master motivation role
 
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
AWS CloudFormation Automation, TrafficScript, and Serverless architecture wit...
 
Prioritization by value (DevOps, Scrum)
Prioritization by value (DevOps, Scrum)Prioritization by value (DevOps, Scrum)
Prioritization by value (DevOps, Scrum)
 
Selenium bootcamp slides
Selenium bootcamp slides   Selenium bootcamp slides
Selenium bootcamp slides
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef Automate
 
DevOps and Chef improve your life
DevOps and Chef improve your life DevOps and Chef improve your life
DevOps and Chef improve your life
 
Behat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdfBehat bdd training (php) course slides pdf
Behat bdd training (php) course slides pdf
 
Foundation selenium java
Foundation selenium java Foundation selenium java
Foundation selenium java
 

Similar to Coding using jscript test complete

HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - Altran
Robert Nyman
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
Giovanni Scerra ☃
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
Slim Ouertani
 
JavaScript Classes and Inheritance
JavaScript Classes and InheritanceJavaScript Classes and Inheritance
JavaScript Classes and Inheritance
marcheiligers
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch
 
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
Robert Nyman
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
LearningTech
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
Tarek Yehia
 
Prototype
PrototypePrototype
Prototype
Aditya Gaur
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
julien.ponge
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
julien.ponge
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
Sajid Mehmood
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
Jonathan Waller
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
julien.ponge
 
Javascript
JavascriptJavascript
Javascript
Aditya Gaur
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
Anders Jönsson
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
Amanda Gilmore
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
rajivmordani
 

Similar to Coding using jscript test complete (20)

HTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - AltranHTML5 APIs - Where no man has gone before! - Altran
HTML5 APIs - Where no man has gone before! - Altran
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 
JavaScript Classes and Inheritance
JavaScript Classes and InheritanceJavaScript Classes and Inheritance
JavaScript Classes and Inheritance
 
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coinsoft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
 
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, MoscowJavaScript APIs - The Web is the Platform - .toster conference, Moscow
JavaScript APIs - The Web is the Platform - .toster conference, Moscow
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of Javascript
 
Prototype
PrototypePrototype
Prototype
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Camp
 
JAVA SE 7
JAVA SE 7JAVA SE 7
JAVA SE 7
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 
PostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL SuperpowersPostgreSQL's Secret NoSQL Superpowers
PostgreSQL's Secret NoSQL Superpowers
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 

More from Viresh Doshi

DevOps terms for 2018
DevOps terms for 2018DevOps terms for 2018
DevOps terms for 2018
Viresh Doshi
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
Viresh Doshi
 
Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges
Viresh Doshi
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agile
Viresh Doshi
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startup
Viresh Doshi
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
Viresh Doshi
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - Calypso
Viresh Doshi
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testing
Viresh Doshi
 

More from Viresh Doshi (8)

DevOps terms for 2018
DevOps terms for 2018DevOps terms for 2018
DevOps terms for 2018
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
 
Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges Scrum master's role - top 20 challenges
Scrum master's role - top 20 challenges
 
Gherkin for test automation in agile
Gherkin for test automation in agileGherkin for test automation in agile
Gherkin for test automation in agile
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startup
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automation
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - Calypso
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testing
 

Recently uploaded

Enhancing Adoption of AI in Agri-food: Introduction
Enhancing Adoption of AI in Agri-food: IntroductionEnhancing Adoption of AI in Agri-food: Introduction
Enhancing Adoption of AI in Agri-food: Introduction
Cor Verdouw
 
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
Cambridge Product Management Network
 
Easy Earnings Through Refer and Earn Apps Without KYC.pptx
Easy Earnings Through Refer and Earn Apps Without KYC.pptxEasy Earnings Through Refer and Earn Apps Without KYC.pptx
Easy Earnings Through Refer and Earn Apps Without KYC.pptx
Fx Lotus
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results
 
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper PresentationKirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results
 
L'indice de performance des ports à conteneurs de l'année 2023
L'indice de performance des ports à conteneurs de l'année 2023L'indice de performance des ports à conteneurs de l'année 2023
L'indice de performance des ports à conteneurs de l'année 2023
SPATPortToamasina
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results
 
TriStar Gold Corporate Presentation - June 2024
TriStar Gold Corporate Presentation - June 2024TriStar Gold Corporate Presentation - June 2024
TriStar Gold Corporate Presentation - June 2024
Adnet Communications
 
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdfPDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
HajeJanKamps
 
Stainless Steel Conveyor Manufacturers Chennai
Stainless Steel Conveyor Manufacturers ChennaiStainless Steel Conveyor Manufacturers Chennai
Stainless Steel Conveyor Manufacturers Chennai
ConveyorSystem
 
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
Adani case
 
Kalyan Chart Satta Matka Dpboss Kalyan Matka Results
Kalyan Chart Satta Matka Dpboss Kalyan Matka ResultsKalyan Chart Satta Matka Dpboss Kalyan Matka Results
Kalyan Chart Satta Matka Dpboss Kalyan Matka Results
Satta Matka Dpboss Kalyan Matka Results
 
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fix
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fixKalyan chart 6366249026 India satta Matta Matka 143 jodi fix
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fix
satta Matta matka 143 Kalyan chart jodi 6366249026
 
High-Quality IPTV Monthly Subscription for $15
High-Quality IPTV Monthly Subscription for $15High-Quality IPTV Monthly Subscription for $15
High-Quality IPTV Monthly Subscription for $15
advik4387
 
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Kanban Coaching Exchange with Dave White - Example SDR Report
Kanban Coaching Exchange with Dave White - Example SDR ReportKanban Coaching Exchange with Dave White - Example SDR Report
Kanban Coaching Exchange with Dave White - Example SDR Report
Helen Meek
 
Pro Tips for Effortless Contract Management
Pro Tips for Effortless Contract ManagementPro Tips for Effortless Contract Management
Pro Tips for Effortless Contract Management
Eternity Paralegal Services
 
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
concepsionchomo153
 

Recently uploaded (20)

Enhancing Adoption of AI in Agri-food: Introduction
Enhancing Adoption of AI in Agri-food: IntroductionEnhancing Adoption of AI in Agri-food: Introduction
Enhancing Adoption of AI in Agri-food: Introduction
 
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
2024.06 CPMN Cambridge - Beyond Now-Next-Later.pdf
 
Easy Earnings Through Refer and Earn Apps Without KYC.pptx
Easy Earnings Through Refer and Earn Apps Without KYC.pptxEasy Earnings Through Refer and Earn Apps Without KYC.pptx
Easy Earnings Through Refer and Earn Apps Without KYC.pptx
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
Kirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper PresentationKirill Klip GEM Royalty TNR Gold Copper Presentation
Kirill Klip GEM Royalty TNR Gold Copper Presentation
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
L'indice de performance des ports à conteneurs de l'année 2023
L'indice de performance des ports à conteneurs de l'année 2023L'indice de performance des ports à conteneurs de l'année 2023
L'indice de performance des ports à conteneurs de l'année 2023
 
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan ChartSatta Matka Dpboss Kalyan Matka Results Kalyan Chart
Satta Matka Dpboss Kalyan Matka Results Kalyan Chart
 
TriStar Gold Corporate Presentation - June 2024
TriStar Gold Corporate Presentation - June 2024TriStar Gold Corporate Presentation - June 2024
TriStar Gold Corporate Presentation - June 2024
 
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdfPDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
PDT 99 - $3.5M - Seed - Feel Therapeutics.pdf
 
Stainless Steel Conveyor Manufacturers Chennai
Stainless Steel Conveyor Manufacturers ChennaiStainless Steel Conveyor Manufacturers Chennai
Stainless Steel Conveyor Manufacturers Chennai
 
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
Adani Group Requests For Additional Land For Its Dharavi Redevelopment Projec...
 
Kalyan Chart Satta Matka Dpboss Kalyan Matka Results
Kalyan Chart Satta Matka Dpboss Kalyan Matka ResultsKalyan Chart Satta Matka Dpboss Kalyan Matka Results
Kalyan Chart Satta Matka Dpboss Kalyan Matka Results
 
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fix
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fixKalyan chart 6366249026 India satta Matta Matka 143 jodi fix
Kalyan chart 6366249026 India satta Matta Matka 143 jodi fix
 
High-Quality IPTV Monthly Subscription for $15
High-Quality IPTV Monthly Subscription for $15High-Quality IPTV Monthly Subscription for $15
High-Quality IPTV Monthly Subscription for $15
 
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka KALYAN MATKA |
 
Kanban Coaching Exchange with Dave White - Example SDR Report
Kanban Coaching Exchange with Dave White - Example SDR ReportKanban Coaching Exchange with Dave White - Example SDR Report
Kanban Coaching Exchange with Dave White - Example SDR Report
 
Pro Tips for Effortless Contract Management
Pro Tips for Effortless Contract ManagementPro Tips for Effortless Contract Management
Pro Tips for Effortless Contract Management
 
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
➒➌➎➏➑➐➋➑➐➐ Satta Matka Dpboss Matka Guessing Indian Matka
 
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
欧洲杯投注-欧洲杯投注外围盘口-欧洲杯投注盘口app|【​网址​🎉ac22.net🎉​】
 

Coding using jscript test complete

  • 1. Test Complete Coding Quick guide to using jScript with Test Complete by SmartBear
  • 2. Create an object/class function myLogFileObject() { this.myPublicObjectArray = []; var myPrivateObjectArray = []; var myPrivateCounter = 0; this.readFunction=function(); return true; } } Why? Nice way to organize functions and variables that represent that object. How to use? var myObject myLogFileObject(); myObject.readFunction();
  • 3. Write to a text file var objFSO = new ActiveXObject("Scripting.FileSystemObject"); var outFile = objFSO.CreateTextFile(FileNameIncludingPath, true,false); outFile.WriteLine("Write me to the file"); outFile.Close();
  • 4. Read a file var file=fso.OpenTextFile (fileLocationAndNameGolden, FileReadOnly); while (!file.AtEndOfStream){ var line=file.ReadLine(); }
  • 5. Try/catch/finally try{ } catch(e){ Log.Message(e.description ); } Finally{ {
  • 6. Copy a file aqFile.Copy (FromFullPathINcludingFileName,ToFullPathIncludingFileNa me, true)
  • 7. Iterate through an array var myArray = []; for(var k=0; k < myArray.length; k++){ outFile.WriteLine(myArray[k]); }
  • 8. Switch statement switch(){ case "": { //do something } case2 "" { //do something } default: { //do something } }
  • 9. Built in Parameters // Built in Parameters function ProcessCommandLine(config) { for (i = 1; i<= BuiltIn.ParamCount();i++){ ProcessCommandLineArgument(BuiltIn.ParamStr(i),config); } }
  • 10. Test Complete aqString aqString.Replace aqString.Trim aqString.Find aqString.ToLower aqString.ChangeListItem aqString.GetListItem aqString.FindLast aqString.GetLength aqString.SubSting( aqString.GetListLength
  • 11. Do loop do{ //some commands }while( something is true)
  • 12. Delete /copy file aqFileSystem.DeleteFile(outPath + newFileName + ".xml"); aqFileSystem.CopyFile(from, to) aqFile.Copy(FromFullPathINcludingFileName,ToFullPathIncl udingFileName, true)
  • 13. Throw error //Check that the object isn't null if (obj == null) throw "Null object passed to generateXMLFromObjectFields";
  • 14. Push an item to an array myArray = []; myArray.push(item);
  • 15. Project variables // access test complete project variables var MyAppPath=Project.Variables.MyAppPath;
  • 16. prototype //prototype var Dog=function(name) { this.name = name; var barkCount = 0; this.bark = function() { barkCount++; Log.Message(this.name + " bark"); }; this.getBarkCount = function() { Log.Message(this.name + " has barked " + barkCount + " times"); };
  • 17. prototype this.wagTail2= function() { Log.Message(this.name + " wagging tail2"); } }; Dog.prototype.wagTail = function() { Log.Message(this.name + " wagging tail"); }; function dog_test(){ var dog = new Dog("Dave"); dog.bark(); dog.bark(); dog.getBarkCount(); dog.wagTail2(); dog.wagTail(); }
  • 18. Extend Array - unique //Extend Array to return unique numbers only Array.prototype.unique = function() { var tmp = {}, out = []; for(var i = 0, n = this.length; i < n; ++i) { if(!tmp[this[i]]) { tmp[this[i]] = true; out.push(this[i]); } } return out; }
  • 19. Read xml objXMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0") objXMLDoc.async = false ; objXMLDoc.setProperty("SelectionLanguage","XPath"); result=objXMLDoc.load(xmlConfigFile); xmlNode=xmlTestConfig.selectSingleNode("TestClass");
  • 20. Read DOM 6.0 xml var objXMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0"); objXMLDoc.async = false; objXMLDoc.setProperty("SelectionLanguage","XPath"); var ns= "xmlns:a='http://smpte-ra. org/schemas/2021/2008/BXF'"; objXMLDoc.setProperty("SelectionNamespaces", ns); ar AsRunList=objXMLDoc.SelectNodes("//a:AsRun");
  • 21. File functions var fso = Sys.OleObject("Scripting.FileSystemObject"); var file = fso.GetFile(file_path); var fol = fso.GetFolder(folder_path); fol.size var filesCount = fol.files.Count;
  • 22. Generate XML from object var docSection = Storages.XML(""); var colFields = aqObject.GetFields(obj, false); var sec = docSection.GetSubSection(root_name);
  • 23. Connect to UDP socket = dotNET.System_Net_Sockets.Socket.zctor( dotNET.System_Net_Sockets.AddressFamily.InterNetwork , dotNET.System_Net_Sockets.SocketType.Dgram, dotNET.System_Net_Sockets.ProtocolType.Udp);
  • 24. SQL Server DB Conn = new ActiveXObject("ADODB.Connection"); var constr= "Provider=SQLOLEDB.1;Data Source=SERVERN;Initial Catalog=cat1;User ID=sa;Password=myPassword"; Conn.Open(constr); var catalogue = new ActiveXObject('ADOX.Catalog'); rs = new ActiveXObject("ADODB.Recordset");
  • 25. Literal Object Create a simple constructor that contains the fields for that object Function User(theParam1){ This.param1 = theParam1; } Extend that object using the Literal prototype feature User.prototype = { Constructor: User, Functoin1: function(theParam2){ …
  • 26. Shorter if/then Variable = (condition) ? True-value : false_value
  • 27. Object fields and methods Var FieldsCol = aqObject.GetFields(Obj); Iterate through the fields while ( FieldsCol.HasNext() ){ Log.Message( FieldsCol.Next().Name ); } Use this to get the methods: aqObject.GetMethods(Obj);

Editor's Notes

  1. // read xml file // Now read other test config items from the XML file objXMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0"); objXMLDoc.async = false ; objXMLDoc.setProperty("SelectionLanguage","XPath"); result=objXMLDoc.load(xmlConfigFile); /* <ITXConfig> <TestConfig> <StartDesktop>False</StartDesktop> <StopDesktop>False</StopDesktop> <ClearWorkspace>True</ClearWorkspace> <KeepLogImages>False</KeepLogImages> <DelayFactor>100</DelayFactor> </TestConfig> </ITXConfig> */ // Report an error, if, for instance, the markup || file structure is invalid if(objXMLDoc.parseError.errorCode != 0){ s = "Reason:" + "\t" + objXMLDoc.parseError.reason + "\r" + "\n" + "Line:" + "\t" + parseInt(objXMLDoc.parseError.line,10) + "\r" + "\n" + "Pos:" + "\t" + parseInt(objXMLDoc.parseError.linePos,10) + "\r" + "\n" + "Source:" + "\t" + objXMLDoc.parseError.srcText // Post an error to the log && exit Log.Error("Cannot parse the document." + s); return false; } var xmlTestConfig =objXMLDoc.SelectSingleNode("//TestConfig"); if(xmlTestConfig==null){ return true; } var xmlDataStr; var xmlNode; /* // Read the TestConfig items from the xml xmlNode=xmlTestConfig.selectSingleNode("TestClass"); if(xmlNode != null){ config.testClass=xmlNode.text; } */ xmlNode=xmlTestConfig.selectSingleNode("StartDesktop"); if(xmlNode != null){ xmlDataStr=xmlNode.text; if(xmlDataStr.toLowerCase() == "true"){ config.startDesktop=true; } else if(xmlDataStr.toLowerCase() == "false"){ config.startDesktop=false; } } var xmlTestClass =objXMLDoc.SelectSingleNode("//TestClass"); config.testClass=(xmlTestClass == null)?"iTXAutoTest":xmlTestClass.Text; xmlTestDescription=objXMLDoc.SelectSingleNode("//TestDescription"); config.scriptComment=(xmlTestDescription == null)?"":xmlTestDescription.Text; var xmlCommands =objXMLDoc.SelectNodes("//Command");
  2. //Read DOM6. based XML documents var objXMLDoc = Sys.OleObject("Msxml2.DOMDocument.6.0"); objXMLDoc.async = false; objXMLDoc.setProperty("SelectionLanguage","XPath"); // We need to do this because DOM6.0 is stricter about security and requires a namespace resolution // By delaring an alias to the namespace here in the properties then we can use the alias (a:) in subsequent selects rather than the full namespace string var ns= "xmlns:a='http://smpte-ra.org/schemas/2021/2008/BXF'"; objXMLDoc.setProperty("SelectionNamespaces", ns); var result=objXMLDoc.load(latestAsRunLogFileFullPath); // Report an error, if, for instance, the markup || file structure is invalid if(objXMLDoc.parseError.errorCode != 0){ var s = "[bxf_GetCountAsRunEvents]Reason:\t" + objXMLDoc.parseError.reason + "\r\n" + "Line:\t" + objXMLDoc.parseError.line + "\r\n" + "Pos:\t" + objXMLDoc.parseError.linePos + "\r\n" + "Source:\t" + objXMLDoc.parseError.srcText; // Post an error to the log && exit Log.Error("Cannot parse the document." + s) return -1; } var AsRunList=objXMLDoc.SelectNodes("//a:AsRun");
  3. //Get size of filefunction getSizeOfFile(file_path) { var fso = Sys.OleObject("Scripting.FileSystemObject"); var file = fso.GetFile(file_path); return file.Size; } function getNameOfFile(strPath) { var rev = strPath.split("").reverse().join(""); var dotIndex = rev.indexOf(""); var ret = rev.substr(dotIndex, rev.indexOf("\\") - dotIndex); var arr = ret.split("").reverse().join("").split("."); return arr[0]; } function getSizeOfFolder(folder_path) { var fso = Sys.OleObject("Scripting.FileSystemObject"); var fol = fso.GetFolder(folder_path); return fol.Size; } function getNoFilesInFolder(folder_path) { var fso = Sys.OleObject("Scripting.FileSystemObject"); var fol = fso.GetFolder(folder_path); var filesCount = fol.files.Count; return filesCount; }
  4. // generate XML from OBject Fields function generateXMLFromObjectFields(obj, root_name, save_path) { //Check that the object isn't null if (obj == null) throw "Null object passed to generateXMLFromObjectFields"; //Get all Fields of the Object var colFields = aqObject.GetFields(obj, false); //Create a new XML document by passing a blank string as the filepath var docSection = Storages.XML(""); //Create the root node var sec = docSection.GetSubSection(root_name); //insert the date sec.SetOption("Date", aqDateTime.Now()); //Create a child node var subSec = sec.GetSubSection("ObjectData"); //Write all fields in the object to the child node while (colFields.HasNext()) { var item = colFields.Next(); if(item.Name != "XMLWriteNested") { if(IsArray(item.Value)) { // var arr = item.Value; // var str = ""; // for(var i = 0; i < arr.length; i++) // { // str += arr[i] + "|"; // } subSec.SetOption(item.Name, item.Value); } else if(GetVarType(item.Value) == 9) { if(IsSupported(item.Value, "OleValue")) { subSec.SetOption(item.Name, item.Value.OleValue); } else if(IsSupported(obj, "XMLWriteNested")) { //insert logic here. } else { subSec.SetOption(item.Name, item.Value); } } else { subSec.SetOption(item.Name, item.Value); } } } //Save the document to the passed filepath docSection.SaveAs(save_path); }
  5. //dot.NET sockets UDP // Send Command and Comment to monitor app.. function MonitorMessage(Command,Comment) { var address, port, socket, broadcast, endpoint, byteType, binaryData, maxLength, sendbuf; var binaryRxData; var MonitorAddress=Project.Variables.MonitorAddress; var MonitorPort=Project.Variables.MonitorPort; if(MonitorAddress==null || MonitorAddress=="" || MonitorPort==null || MonitorPort==0) { return false; } socket = dotNET.System_Net_Sockets.Socket.zctor( dotNET.System_Net_Sockets.AddressFamily.InterNetwork, dotNET.System_Net_Sockets.SocketType.Dgram, dotNET.System_Net_Sockets.ProtocolType.Udp); broadcast = dotNET.System_Net.IPAddress.Parse(MonitorAddress); endpoint = dotNET.System_Net.IPEndPoint.zctor_2(broadcast, MonitorPort); byteType = dotNET.System.Type.GetType("System.Byte"); binaryData = dotNET.System_Text.Encoding.ASCII.GetBytes_2(Command + "|" + Comment); socket.SendTo(binaryData, endpoint);a } function MonitorProgress (progressStr) { MonitorMessage("MonitorProgress",progressStr); } function MonitorEnd () { // Don;t shut down remote monitors.. (i.e. if we didn;t start it locally) // Check if monitor has been specified in project variables var MonitorAppPath=Project.Variables.MonitorAppPath; if(MonitorAppPath==null || MonitorAppPath=="") { return false; } MonitorMessage("MonitorEnd",""); } function MonitorTitle (titleStr) { MonitorMessage("MonitorTitle",titleStr); } function test_DelayCountdownWithProgressMonitor(){ ret=DelayCountdownWithProgressMonitor(3000); } function DelayCountdownWithProgressMonitor(milliSecs) { var delay = milliSecs/1000; var countdown = 0; while( countdown < delay ){ aqUtils.Delay(1000); MonitorProgress("Pausing for " + delay + " secs.." + (delay-countdown)); countdown++; } return; }
  6. function TestADO() { var Conn, Rs, Fldr; //Fldr = Log.CreateFolder("Authors table"); //Log.PushLogFolder(Fldr); // Creates and opens a connection try { Conn = new ActiveXObject("ADODB.Connection"); var constr= "Provider=SQLOLEDB.1;Data Source=SVRQA1116;Initial Catalog=itx;User ID=sa;Password=Omn1bu51tx"; Log.Message("Provider defult=" + Conn.Provider); // Conn.ConnectionString = constr; Conn.Open(constr); } catch(err) { Log.Error(err.description); return false; } var catalogue = new ActiveXObject('ADOX.Catalog'); catalogue.ActiveConnection = Conn; for(var i = 0; i < catalogue.Tables.Count; i++) { var tab = catalogue.Tables.item(i); for(var j = 0; j < tab.Columns.Count; j++) { Log.Message(tab.Name + " : " + tab.Columns.item(j).Name); } } Conn.Close(); // // Creates and opens a recordset // Rs = new ActiveXObject("ADODB.Recordset"); // //Rs.Open("Authors", Conn, 3 /* adOpenStatic */, // //1 /* adLockReadOnly */, 2 /* adCmdTable */); // // // Processes data // Rs.MoveFirst(); // // while(!Rs.EOF) // { // Log.Message(Rs.Fields.Item("Author").Value); // Rs.MoveNext(); // } // // // Closes the recordset and connection // Rs.Close(); } function getDataFromDB(strQuery) { var conn = new ActiveXObject("ADODB.Connection"); var connStr = "Provider=SQLOLEDB.1;Data Source=SVRQA1116;Initial Catalog=itx;User ID=sa;Password=Omn1bu51tx"; try { conn.Open(connStr); } catch (err) { Log.Error('Cannot open connection to database'); return; } var rs = new ActiveXObject("ADODB.Recordset"); try { rs.Open(strQuery, conn); } catch (err) { conn.Close(); throw err; } var res = []; if(!rs.EOF) { rs.MoveFirst(); var titles = []; for(var i = 0; i < rs.Fields.Count; i++) { titles.push(rs.Fields(i).Name); } res.push(titles); while(!rs.EOF) { var row = [] for(var i = 0; i < rs.Fields.Count; i++) { row.push(rs.Fields(i).Value); } res.push(row); rs.MoveNext(); } } rs.Close(); conn.Close(); return res; } function recordExistsInDB(strAssetName, strType) { var table = ""; var column = ""; switch(strType.toUpperCase()) { case 'VIDEO': table = "Opus_VideoClip_VCP"; column = "VCP_Name" break; case 'AUDIO': table = "Opus_AudioClip_ACP"; column = "ACP_Name" break; case 'LOGO': table = "Opus_Logo_LGO"; column = "VCP_Name" break; case 'GRAPHICS': table = "Opus_Graphic_GFX"; column = "VCP_Name" break; case 'SCHEDULE': table = "Opus_Schedule_SCH"; column = "VCP_Name" break; default: var err = new Error(); err.description = "could not resolve type string " + strType + ". Valid options are 'video', 'audio', 'logo', 'graphics' and 'schedule'."; throw err } var strQuery = "SELECT 1 FROM [ITX].[dbo].[" + table + "] WHERE [" + column + "] = '" + strAssetName + "'" var conn = new ActiveXObject("ADODB.Connection"); var connStr = "Provider=SQLOLEDB.1;Data Source=SVRQA1116;Initial Catalog=itx;User ID=sa;Password=Omn1bu51tx"; try { conn.Open(connStr); } catch (err) { Log.Error('Cannot open connection to database'); return; } var rs = new ActiveXObject("ADODB.Recordset"); try { rs.Open(strQuery, conn); } catch (err) { conn.Close(); throw err; } var exists = !rs.EOF rs.Close(); conn.Close(); return exists; } function DB_GetVideoAssetData(strAssetName) { return getDataFromDB("SELECT * FROM [ITX].[dbo].[Opus_VideoClip_VCP] WHERE [VCP_Name] = '" + strAssetName + "'"); } function DB_GetAudioAssetData(strAssetName) { return getDataFromDB("SELECT * FROM [ITX].[dbo].[Opus_AudioClip_ACP] WHERE [ACP_Name] = '" + strAssetName + "'"); } function DB_GetLogoAssetData(strAssetName) { return getDataFromDB("SELECT * FROM [ITX].[dbo].[Opus_Logo_LGO] WHERE [LGO_Name] = '" + strAssetName + "'"); } function DB_GetGraphicsAssetData(strAssetName) { return getDataFromDB("SELECT * FROM [ITX].[dbo].[Opus_Graphic_GFX] WHERE [GFX_Name] = '" + strAssetName + "'"); } function DB_GetScheduleAssetData(strAssetName) { return getDataFromDB("SELECT * FROM [ITX].[dbo].[Opus_Schedule_SCH] WHERE [SCH_Name] = '" + strAssetName + "'"); } function tstDBAccess() { var a = DB_GetVideoAssetData('AET-CMAP-000236'); var b = DB_GetAudioAssetData('BNE015_2'); var c = DB_GetGraphicsAssetData('20th_Century_Fox'); var d = DB_GetLogoAssetData('20th_Century_Fox'); var e = DB_GetScheduleAssetData('SVRQA1117'); e; } function tstdoesExist() { var s = recordExistsInDB('BNE015_1', 'audio'); }
  7. http://blog.pluralsight.com/the-prototype-pattern-structuring-javascript-code-part-ii http://javascriptissexy.com/oop-in-javascript-what-you-need-to-know/?WPACFallback=1&WPACRandom=1418040605766 Implementation of Combination Constructor/Prototype Pattern The User Function: I will explain each line. function User (theName, theEmail) { this.name = theName; this.email = theEmail; this.quizScores = []; this.currentScore = 0; } User.prototype = { constructor: User, saveScore:function (theScoreToAdd) { this.quizScores.push(theScoreToAdd) }, showNameAndScores:function () { var scores = this.quizScores.length > 0 ? this.quizScores.join(",") : "No Scores Yet"; return this.name + " Scores: " + scores; }, changeEmail:function (newEmail) { this.email = newEmail; return "New Email Saved: " + this.email; } } Make Instances of the User function // A User firstUser = new User("Richard", "Richard@examnple.com"); firstUser.changeEmail("RichardB@examnple.com"); firstUser.saveScore(15); firstUser.saveScore(10); firstUser.showNameAndScores(); //Richard Scores: 15,10 // Another User secondUser = new User("Peter", "Peter@examnple.com"); secondUser.saveScore(18); secondUser.showNameAndScores(); //Peter Scores: 18
  8. function GettingObjectProperties(Obj) { // Obtains the fields collection var FieldsCol = aqObject.GetFields(Obj); Log.Message("The fields are:"); // Posts the fields names to the test log while ( FieldsCol.HasNext() ){ Log.Message( FieldsCol.Next().Name ); } // Obtains the collection of methods var colMethods = aqObject.GetMethods(Obj); Log.Message("The methods are:"); while (colMethods.HasNext()){ Log.Message(colMethods.Next().Name); } }