SlideShare a Scribd company logo
1 of 27
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

Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021
Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021
Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021Amazon Web Services Korea
 
Oracle Cloud Infrastructure:2022年10月度サービス・アップデート
Oracle Cloud Infrastructure:2022年10月度サービス・アップデートOracle Cloud Infrastructure:2022年10月度サービス・アップデート
Oracle Cloud Infrastructure:2022年10月度サービス・アップデートオラクルエンジニア通信
 
The right path to making search relevant - Taxonomy Bootcamp London 2019
The right path to making search relevant  - Taxonomy Bootcamp London 2019The right path to making search relevant  - Taxonomy Bootcamp London 2019
The right path to making search relevant - Taxonomy Bootcamp London 2019OpenSource Connections
 
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud Services
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud ServicesOracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud Services
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud ServicesMichael Hichwa
 
Hadoop and Financial Services
Hadoop and Financial ServicesHadoop and Financial Services
Hadoop and Financial ServicesCloudera, Inc.
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQL
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQLAnnouncing Amazon Athena - Instantly Analyze Your Data in S3 Using SQL
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQLAmazon Web Services
 
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...Amazon Web Services
 
AnalytiX DS - Master Deck
AnalytiX DS - Master DeckAnalytiX DS - Master Deck
AnalytiX DS - Master DeckAnalytiX DS
 
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기Amazon Web Services Korea
 
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...Amazon Web Services Korea
 
Oracle architecture
Oracle architectureOracle architecture
Oracle architectureSoumya Das
 
AWS 資格試験対策講座
AWS 資格試験対策講座AWS 資格試験対策講座
AWS 資格試験対策講座Kameda Harunobu
 
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018Amazon Web Services Korea
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfMySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfAlkin Tezuysal
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsGokhan Atil
 

What's hot (20)

Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021
Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021
Oracle DB를 AWS로 이관하는 방법들 - 서호석 클라우드 사업부/컨설팅팀 이사, 영우디지탈 :: AWS Summit Seoul 2021
 
Oracle Cloud Infrastructure:2022年10月度サービス・アップデート
Oracle Cloud Infrastructure:2022年10月度サービス・アップデートOracle Cloud Infrastructure:2022年10月度サービス・アップデート
Oracle Cloud Infrastructure:2022年10月度サービス・アップデート
 
The right path to making search relevant - Taxonomy Bootcamp London 2019
The right path to making search relevant  - Taxonomy Bootcamp London 2019The right path to making search relevant  - Taxonomy Bootcamp London 2019
The right path to making search relevant - Taxonomy Bootcamp London 2019
 
Oracle GoldenGate
Oracle GoldenGate Oracle GoldenGate
Oracle GoldenGate
 
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud Services
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud ServicesOracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud Services
Oracle APEX, Oracle Autonomous Database, Always Free Oracle Cloud Services
 
Hadoop and Financial Services
Hadoop and Financial ServicesHadoop and Financial Services
Hadoop and Financial Services
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
AWS Fargate on EKS 실전 사용하기
AWS Fargate on EKS 실전 사용하기AWS Fargate on EKS 실전 사용하기
AWS Fargate on EKS 실전 사용하기
 
Alfresco紹介
Alfresco紹介Alfresco紹介
Alfresco紹介
 
HCL AppScan 10 のご紹介
HCL AppScan 10 のご紹介HCL AppScan 10 のご紹介
HCL AppScan 10 のご紹介
 
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQL
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQLAnnouncing Amazon Athena - Instantly Analyze Your Data in S3 Using SQL
Announcing Amazon Athena - Instantly Analyze Your Data in S3 Using SQL
 
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...
Airbnb's Journey from Self-Managed Redis to ElastiCache for Redis (DAT319) - ...
 
AnalytiX DS - Master Deck
AnalytiX DS - Master DeckAnalytiX DS - Master Deck
AnalytiX DS - Master Deck
 
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
Amazon EMR과 SageMaker를 이용하여 데이터를 준비하고 머신러닝 모델 개발 하기
 
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...
E-Commerce 를 풍성하게 해주는 AWS 기술들 - 서호석 이사, YOUNGWOO DIGITAL :: AWS Summit Seoul ...
 
Oracle architecture
Oracle architectureOracle architecture
Oracle architecture
 
AWS 資格試験対策講座
AWS 資格試験対策講座AWS 資格試験対策講座
AWS 資格試験対策講座
 
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
AWS Kubernetes 서비스 자세히 살펴보기 (정영준 & 이창수, AWS 솔루션즈 아키텍트) :: AWS DevDay2018
 
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdfMySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
MySQL Ecosystem in 2023 - FOSSASIA'23 - Alkin.pptx.pdf
 
Oracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAsOracle Enterprise Manager Cloud Control 13c for DBAs
Oracle Enterprise Manager Cloud Control 13c for DBAs
 

Viewers also liked

Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test CompleteVartika Saxena
 
Automation Testing with TestComplete
Automation Testing with TestCompleteAutomation Testing with TestComplete
Automation Testing with TestCompleteRomSoft SRL
 
Script Driven Testing using TestComplete
Script Driven Testing using TestCompleteScript Driven Testing using TestComplete
Script Driven Testing using TestCompletesrivinayak
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_completebinuiweb
 
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 SmartBearSoftware Testing Solution
 
Keyword Driven Testing using TestComplete
Keyword Driven Testing using TestCompleteKeyword Driven Testing using TestComplete
Keyword Driven Testing using TestCompletesrivinayak
 
TestComplete 7.50 New Features
TestComplete 7.50 New FeaturesTestComplete 7.50 New Features
TestComplete 7.50 New FeaturesVlad Kuznetsov
 
social prez - mpcc - mholterhaus
social prez - mpcc - mholterhaussocial prez - mpcc - mholterhaus
social prez - mpcc - mholterhausmholterhaus
 
Web Service Testing using TestComplete
Web Service Testing using TestCompleteWeb Service Testing using TestComplete
Web Service Testing using TestCompletesrivinayak
 
Scrum master motivation role
Scrum master motivation roleScrum master motivation role
Scrum master motivation roleViresh 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
 
AWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomateAWS OpsWorks for Chef Automate
AWS OpsWorks for Chef AutomatePolarSeven Pty Ltd
 
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 pdfseleniumbootcamp
 

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! - AltranRobert Nyman
 
JavaScript Classes and Inheritance
JavaScript Classes and InheritanceJavaScript Classes and Inheritance
JavaScript Classes and Inheritancemarcheiligers
 
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 Coinsoft-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, MoscowRobert 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 oopLearningTech
 
Art of Javascript
Art of JavascriptArt of Javascript
Art of JavascriptTarek Yehia
 
Java 7 at SoftShake 2011
Java 7 at SoftShake 2011Java 7 at SoftShake 2011
Java 7 at SoftShake 2011julien.ponge
 
Java 7 JUG Summer Camp
Java 7 JUG Summer CampJava 7 JUG Summer Camp
Java 7 JUG Summer Campjulien.ponge
 
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 SuperpowersAmanda Gilmore
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5arajivmordani
 

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 2018Viresh Doshi
 
Ansible top 10 - 2018
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018Viresh 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 agileViresh Doshi
 
Devops Journey - internet tech startup
Devops Journey - internet tech startupDevops Journey - internet tech startup
Devops Journey - internet tech startupViresh Doshi
 
Continuous test automation
Continuous test automationContinuous test automation
Continuous test automationViresh Doshi
 
Capital markets testing - Calypso
Capital markets testing - CalypsoCapital markets testing - Calypso
Capital markets testing - CalypsoViresh Doshi
 
Collaboration in testing
Collaboration in testingCollaboration in testing
Collaboration in testingViresh 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

Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with CultureSeta Wicaksana
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxAndy Lambert
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyEthan lee
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Centuryrwgiffor
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Roland Driesen
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Neil Kimberley
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfAdmir Softic
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsMichael W. Hawkins
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxpriyanshujha201
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxWorkforce Group
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMRavindra Nath Shukla
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communicationskarancommunications
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear RegressionRavindra Nath Shukla
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfAmzadHosen3
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...Aggregage
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Dipal Arora
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...Paul Menig
 

Recently uploaded (20)

Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Famous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st CenturyFamous Olympic Siblings from the 21st Century
Famous Olympic Siblings from the 21st Century
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdfDr. Admir Softic_ presentation_Green Club_ENG.pdf
Dr. Admir Softic_ presentation_Green Club_ENG.pdf
 
HONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael HawkinsHONOR Veterans Event Keynote by Michael Hawkins
HONOR Veterans Event Keynote by Michael Hawkins
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Pharma Works Profile of Karan Communications
Pharma Works Profile of Karan CommunicationsPharma Works Profile of Karan Communications
Pharma Works Profile of Karan Communications
 
Regression analysis: Simple Linear Regression Multiple Linear Regression
Regression analysis:  Simple Linear Regression Multiple Linear RegressionRegression analysis:  Simple Linear Regression Multiple Linear Regression
Regression analysis: Simple Linear Regression Multiple Linear Regression
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...7.pdf This presentation captures many uses and the significance of the number...
7.pdf This presentation captures many uses and the significance of the number...
 

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); } }