Subscribe via E-mail

Your email:

published qa papers free

Browse by Tag

Posts by Month

Follow Me

NTT DATA Canada Discussion Room

Current Articles | RSS Feed RSS Feed

Test Automation Scripting Language - Part 3 of 3

 

Test Automation Scripting Language - Part 3 of 3

What is Scripting Language and How is it Used?

Automation Scripting resized 600

Written by Vijay Deshmukh

Strings

A variable can hold strings using following format

Dim aStringVariable

aStringVariable = “Simple Text”

There are different string related functions such as Len, Right, Left, UCase, LCase etc.

  

Let us consider a small example of reading a text file:

Dim objFile, strFilePath

strFilePath = “c:\sample.txt”

Set objFile = CreateObject(“Scripting.FileSystemObject”)

If objFile.FileExists(strFilePath) then

                Set objReadFile = objFile.OpenTextFile(strFilePath, ForReading)

Do While objReadFile.AtEndOfStream <> True then

                Msgbox objReadFile.ReadLine

Loop

objReadFile.Close

Else

                MsgBox “File “& strFilePath & “ is not found.”

End

Set objFile = Nothing

Let us analyse the code:

CreateObject will create a file system object.

FileExists will check if the file is available at the specified location.

OpenTextFile will open the file. The first argument this function is file path and second argument is if the file is to be opened for Reading, Writing or Apending. In our case it is for reading.

Next Do While loop will read the file line by line and message box will display this line.

The condition to exit the Do While loop is the end of file. This is done using AtEndOfStream.

After the loop, the line objRedFile.Close will close the file.

If the file is not available at specified location, a message is displayed to the user. This is covered in Else part of If..Then condition.

FileSystemObject is created in above example. Similarly, one can create objects for different applications so they can be automated using VB Script. Following are some of the examples:

CreateObject(“Excel.Application”) to create MS-Excel object.

CreateObject(“Outlook.Application”) to create MS-outlook object.

CreateObject(“Word.Application”) to create MS-Word object

CreateObject(“QuickTest.Application”) to create QTP object.

Like any other application object, QTP object is used to launch QTP during batch mode, to add object repositories dynamically and to add library files dynamically etc.

In similar way, VB Script can be used in simple to medium as well as complex scripting such as generating reports at the end of every script run, sending automatic emails to analyse the test run reports or even logging defects automatically in a defect tracking tool.

As you learn VB Script and become more conversant with the syntax of the in-built functions, usage of the methods, you can create complex scenarios. With QTP’s strong object recording mechanism and power of VB script, most of the manual test cases can be automated.

Other uses of Scripting Languages:

  • Development of agents which can be used to build an automation test bed and running automation scripts on multiple machines at the same time
  • Integration with hardware devices using device drivers
  • Scheduling test runs
  • Development of stubs and drivers in early phase of code development and unit testing
  • Automation of unit test cases
  • Development of end to end automation from: creating a build after code merge, unit testing, smoke testing, regression testing, sending the test run reports through email and raising the defects in defect tracking tool

Conclusion:

In conclusion, scripting language in cohesion with suitable automated testing tool can reduce manual efforts drastically.  These efforts can be better utilized for analysing the results as well as executing the tests which cannot be automated.

Resources:

Java Script: http://javascript.internet.com/

VBScript: http://msdn.microsoft.com/en-us/library/t0aew7h6(v=vs.85).aspx

TCL: www.tcl.tk

Python: www.python.org

Ruby: http://www.ruby-lang.org/en/

Perl: http://www.perl.org/

PHP: http://www.php.net/

test automation services

The opinions expressed on this discussion room are writer's and don't necessarily represent NTT DATA Canada's positions, strategies or opinions.

Comments

Posted on Linked in By Vikas Garg in Linked in http://www.linkedin.com/groupAnswers?viewQuestionAndAnswers=&discussionID=87509071&gid=55772&commentID=63407725&trk=view_disc&ut=1QdutNIEQaiR41 
 
 
 
Scripting languages are one that are interpreted rather than being compiled. 
 
Interpretation means that the native code is changed to machine code line by line.  
 
Posted @ Wednesday, January 11, 2012 8:03 AM by JORRIT WIT
Posted on Linked in By Fred Sookiasian in Linked in http://www.linkedin.com/groupAnswers?viewQuestionAndAnswers=&discussionID=87509071&gid=55772&commentID=63407725&trk=view_disc&ut=1QdutNIEQaiR41  
 
 
 
Also, scripting languages are triggered during the "run time" of an application, or as many would state, during the Black Box testing phase. I've often dealt with developers who have very little QA background, especially testing tools. While most resourceful developers (especially one's using latest iterations of .Net etc) write their own unit test hooks, I see a huge smile on their face when they see Quick Test Pro in action especially with some highly customized automated scripts doing a number of test validations (data driven, keyword, etc). Again, it's one world to do unit test validation but it's a whole other when you have somehting as sophisticated as a testing tool doing run-time validation with some code!  
 
Posted @ Wednesday, January 11, 2012 8:07 AM by JORRIT WIT
Responses from Vijay below 
 
To Vikas: Compiler compiles all program in high level instructions or code in machine language. Interpreter coverts each statement from high level to machine language. language. 
 
While executing, in compilation, entire program needs to be compiled and linked to the linker whereas in interpretation if each line is interpreted, it can be executed. 
 
Another differentiating factor is speed. Since interpreter converts each statement into machine language and executes it, it becomes slow.  
 
 
 
To Fred: Yes. During the initial automation or unit testing phase, when entire application is not ready, scripting languages play vital role in developing stubs and drivers. Today’s sophisticated test tools generate the scripting language at the click of few mouse buttons but if one understands core scripting it becomes very easy to enhance the scripts
Posted @ Wednesday, January 11, 2012 8:33 AM by JORRIT WIT
Scripting language is a programming language which allows to control of one or more applications. Scripting language is also known as extension language. 
 
Though I don't know scripting language but the above comments are very useful to me.
Posted @ Friday, January 13, 2012 3:41 AM by Prakhar Dasgupta
Post Comment
Name
 *
Email
 *
Website (optional)
Comment
 *

Allowed tags: <a> link, <b> bold, <i> italics