Automation Testing, Manual Testing, QTP/UFT 11 , QC/ALM 11 ,SAP TAO, Unix, Selenium, Oracle SQL, Shell Scripting and For Online Trinings to contact me : Cell:+91-8897972059 , Email Id : quicktestprotech@gmail.com

Tuesday, November 30, 2010

VB Script Keywords

VBScript Keywords

Keyword
Description
Empty
Used to indicate an uninitialized variable value. A variable value is uninitialized when it is first created and no value is assigned to it, or when a variable value is explicitly set to empty.
dim x   'the variable x is uninitialized!
x="ff"   'the variable x is NOT uninitialized anymore
x=empty   'the variable x is uninitialized!

Note: This is not the same as Null!!
False
Has a value equal to 0
Nothing
Used to disassociate an object variable from an object to release system resources.
Example: set myObject=Nothing
Null
Used to indicate that a variable contains no valid data.
Note: This is not the same as Empty!!
True
Has a value equal to -1

VBScript Keywords

Sunday, November 28, 2010

QTP Scripts Best Examples

 Character Search in a Given String

Sub Main()

‘Get the string from input box and character from another input box

ipbox = InputBox("enter the string to search", "String name")
ipbox1 = InputBox("enter the character to search", "Character")
ipbox2 = InputBox("enter the character to search", "Character")
‘Length of the String

len1 = Len(ipbox)

j = 0

‘For Loop to get character by character

For i = 1 To len1

‘Using Mid(string,start,Length) function to get single character

ret = Mid(ipbox, i, 1)
re = Mid(ipbox, i, 1)

‘if the single character matches input character then the count increase by 1

If ret = ipbox1 Then
j = j + 1
End If

If re = ipbox2 Then
'k = k + 1
'End If

Next
‘Retrieving the number of character in Message Box

MsgBox "Number of   " & ipbox1 & "  in the string " & ipbox & "  is  " & j
MsgBox "Number of   " & ipbox2 & "  in the string " & ipbox & "  is  " & k
End Sub

‘End Script
Sub Main()

‘Create object using scripting.filesystemobject

Set fs = CreateObject("Scripting.Filesystemobject")

‘Open the Text file and set to variable

Set f = fs.opentextfile("c:\documents and settings\thirupathi\desktop\thiru.txt")

‘While loop for getting line by line till end of line

While f.atendofline <> True


x = f.readline

MsgBox x

‘Close the Text file

f.close
Wend

End Sub


Sub main()

ibox = InputBox("Enter number between 1 to 5", "number")

‘call function validate

validate (ibox)

End Sub

Function

Function validate(number)

‘Select Case statement

Select Case number
Case 1
MsgBox "Select 1"
Case 2
MsgBox "Select 2"
Case 3
MsgBox "select 3"
Case 4
MsgBox "select 4"
Case 5
MsgBox "select 5"

End Select
End Function

Script: How to handle HTML Table

Retrieving the exact data from HTML Table

Sub main()


‘Declare the table as THTMLTable
‘Declare the table data as THTMLTD

Dim h, z As Integer
Dim tab1 As THTMLTable
Dim td As THTMLTD
Dim td1 As THTMLTD

‘Set the table with the Table ID

Set tab1 = HTMLTable("ID =")

‘Set the table data with the Table ID and Index of the particular cell
Set td = HTMLTD("ID= '' Index = 5")
Set td1 = HTMLTD("ID= '' Index = 6")

‘retrieving the data of the cell
r = td.Text
MsgBox r
s = td1.Text
MsgBox s
‘retrieving the Table Height and Table Width

h = tab1.Height
z = tab1.Width
MsgBox h
MsgBox z


End Sub

‘End Script



Sub main()

‘Declare the table as THTMLTable

Dim a As THTMLTable

‘Set the table with the Table ID

Set a = HTMLTable("ID= ")

‘In table Table items is set variable

r = a.Items.Count
c = a.Items(1).Count

‘Loop for getting data one by one

For i = 1 To r
For j = 1 To c

‘Retrieve all the data in the Table

val1 = a.Items(i).Item(j)
MsgBox val1
Next
Next


End Sub

‘End Script

‘Declare the array fir(500) and sec(500) to store line by line string
‘Declare j,k as variant

Dim frec As String
Dim srec As String
Dim fir(500), sec(500) As String
Dim j, k As Variant
Dim fs


Sub main()
j = 1
k = 1

‘Create the object using “scripting.filesystemobject” and set it to fs

Set fs = CreateObject("scripting.filesystemobject")

‘Open the corresponding file “file1” to compare. Make it as 1st File number

Open "c:\Documents and Settings\Thirupathi\Desktop\thiru.txt" For Input As #1

‘while loop till end of file

While Not EOF(1)

‘Each and every line of text file is passed to “frec”

Line Input #1, frec

‘storing “frec” to array

fir(j) = frec

j = j + 1

Wend

‘Close the File

Close #1

‘Open the corresponding file “File 2” to compare. Make it as 1st File number

Open "c:\Documents and Settings\Thirupathi\Desktop\thiru1.txt" For Input As #1


‘while loop till end of file

While Not EOF(1)

‘Each and every line of text file is passed to “srec”

Line Input #1, srec

‘storing “srec” to array

sec(k) = srec
 k = k + 1
Wend

‘Close the File

Close #1

‘Create the new text file using createtextfile() method

Set ws = fs.createtextfile("C:\xxx.txt", True)

‘For loop for each and every line

For i = 1 To j

‘Condition for comparing line by line check on both the text files

If fir(i) = sec(i) Then

‘If both the line matches
‘Write the status to the newly created file

ws.WriteLine ("Line Number: " & i & "  Same" & "   " & fir(i) & "  " & sec(i))
Else

‘If both the line not matches
‘Write the status to the newly created file

ws.WriteLine ("Line Number: " & i & "  Not Same" & "   " & fir(i) & "  " & sec(i))
End If
Next

‘Close the created file

Ws.close
End Sub

‘End Script

Script to retrieve all the data from html table
 
Sub Main()

' Declare THTML Table

Dim a As THTMLTable
Set a = HTMLTable("ID= ")
' get the data using a.items.count

r = a.Items.Count
c = a.Items(1).Count

' get the input through inputbox

st = InputBox("Enter the contents")

' Loop to get all the data from table

For i = 1 To r
For j = 1 To c

val1 = a.Items(i).Item(j)

' String comparison of input value and found value

celltext = StrComp(st, val1, vbTextCompare)

' if condition: if the string matches the boolean value is 0
' otherwise 1

If celltext = 0 Then

'Display the data in msgbox

MsgBox val1

End If

Next
Next

End Sub

‘End Script

Script for connecting to the Database (Retrieving All the Data)


'In Tools -> References Select "Microsoft Active Data Object 2.7 Library
'Select "Microsoft Active Data Object Record Set 2.7 Library

Sub Main()

'Declare new ADODB.connection
'Declare new ADODB.recordset


Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

'Open the connection using DSN

con.Open "DSN=Testdsn1"

' Sql Query to retrieve the Entire Data in Table

sql = "select * from phone"

' Open the Recordset using sql, connection, adopendynamic ,ad lockoptimistic

rs.Open sql, con, adOpenDynamic, adLockOptimistic

'Create while - loop for getting one by one record till EOF

While rs.EOF <> True
ret = rs(0)
re = rs(1)
MsgBox rs(0) & " " & rs(1)
rs.MoveNext
Wend

'Close the connection

con.Close



End Sub


‘End Script
Script for connecting to the Database (Writing Data)


'In Tools -> References Select "Microsoft Active Data Object 2.7 Library
'Select "Microsoft Active Data Object Record Set 2.7 Library

Sub Main()

'Declare new ADODB.connection
'Declare new ADODB.recordset


Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

'Open the connection using DSN

con.Open "DSN=Testdsn1"

' Sql Query to retreive the Entire Data in Table

sql = "select * from phone"

' Open the Recordset using sql, connection, adopendynamic ,ad lockoptimistic

rs.Open sql, con, adOpenDynamic, adLockOptimistic

‘Adding New record

rs.addnew
rs(0) = “Thirupathi”
rs(1)= “123456”

‘Updating the Record
rs.update

'Close the connection

con.Close



End Sub


‘End Script

Script using ACTIVE X . dll (i.e.) Handling DLL with USERFORM as Front End


‘Initially Create Active X dll in Visual Basic 6.0
‘Select Active X dll from New Project
‘In the Class module write the function ADD, SUBTRACT, MUL, DIV

‘Function 1
‘get arguments through variable  “a” and “b”

Sub add(a As Integer, b As Integer)

Dim c As Integer
c = a + b
MsgBox c

End Sub

‘Function 2
‘get arguments through variable  “a” and “b”

Sub subtract(a As Integer, b As Integer)

Dim c As Integer
c = a - b
MsgBox c

End Sub

‘Function 3
‘get arguments through variable  “a” and “b”

Sub mul(a As Integer, b As Integer)

Dim c As Integer
c = a * b
MsgBox c

End Sub

‘Function 4
‘get arguments through variable  “a” and “b”

Sub div(a As Integer, b As Integer)

Dim c As Integer
c = a / b
MsgBox c

End Sub

‘End Function
‘Save as “arithmetic.dll”
‘make arithmetic.dll   from File -> Make arithmetic.dll

<!--[if !vml]--><!--[endif]-->

‘In Test Partner Create Userform  “ Asset Browser -> Userform -> New Userform
‘Create Label, Text Box and Command Button in Form as shown below


<!--[if !vml]--><!--[endif]-->

‘In Code Editor write the following code

Dim s As Integer
Dim z As Integer
Dim temp As New Class1

‘write the caption = “ADD” and  name = “addition” for command button 1

Private Sub addition_Click()

s = TextBox1.Text
z = TextBox2.Text

‘Call the Function “Addition”
‘Pass Arguments through “s”, “z”

Call temp.Add(s, z)

End Sub

‘write the caption = “SUB” and  name = “subtract” for command button 2

Private Sub subtract_Click()

s = TextBox1.Text
z = TextBox2.Text


‘Call the Function “Subtract”
 ‘Pass Arguments through “s”, “z”

Call temp.subtract(s, z)

End Sub

‘write the caption = “MUL” and  name = “multiply” for command button 3

Private Sub multiply_Click()

s = TextBox1.Text
z = TextBox2.Text

‘Call the Function “Multiply”
 ‘Pass Arguments through “s”, “z”

Call temp.mul(s, z)

End Sub

‘write the caption = “DIV” and  name = “division” for command button 4


Private Sub divide_Click()

s = TextBox1.Text
z = TextBox2.Text

‘Call the Function “Divide”
 ‘Pass Arguments through “s”, “z”

Call temp.div(s, z)

End Sub

‘End Function
‘Save as “User1”
<!--[if !vml]--><!--[endif]-->

‘In Test Partner create New Script and Name as “handlingDLL” 
‘In VBA code window write the following Code

Sub Main()

‘Including the Userform “user1”

Include "user1"
User1.Show

End Sub

‘End Script
Script for Handling Active X control using “Data Grid”

1.‘In Visual Basic 6.0  select Standard EXE from New Project
2‘Add Reference to the project by selecting “Project -> Components -> Microsoft DataGrid
‘Control 6.0(OLEDB) and Microsoft ADO Data Control 6.0 (OLEDB)

3.‘Add the “adodc” and “DataGrid” to the form by double clicking the corresponding component from   ‘the left pane of the visual basic window.
4.‘Write Click ADODC in the form and select ADODC Properties
5.‘In property pages click “use ODBC Data Source Name”.  Select from the existing DSN or Create a new DSN and link the database.
6.‘Goto “RecordSource” and select “2. adCmdTable” from Command Type
7.‘Select “Table Name” from Table or Store Procedure
8.‘Click “Apply” and “ok”

9.‘In DataGrid Properties Select DataSource “ADODC1”

10.‘Press F5 to run the project. The DataGrid display the rows and columns of the Table in the Database
11. ‘Make EXE file by “File -> Make “project name”.exe

<!--[if !vml]--><!--[endif]-->

In Test Partner write the following code

Sub main()

‘Declare Tactive X

Dim a As TActiveX

‘Identify the Data Grid and set to the variable

Set a = ActiveX("Name=DataGrid1 ClassName=DataGrid")

‘Retrieving the rows and columns
r = a.Object.visiblerows
c = a.Object.visiblecols

‘Get the Text from input box

string1 = InputBox("Enter the Name")

‘Link the row and column to the corresponding variables

For ir = 0 To r - 1
a.Object.row = ir

For ic = 0 To c - 1
a.Object.col = ic

‘Get the Cell Text at the cursor position
d = a.Object.Text

‘Compare the input text to the obtained text and the result will be in Boolean

celltext = StrComp(string1, d, vbTextCompare)

‘Condition: If celltext value is 0 then display the rows
If celltext = 0 Then

MsgBox "Text in Row: " & ir & " Column: " & ic
End If
Next
Next

End Sub


‘End Script
‘Save the script as “handlingDLL”

Reading Sheet 1 and Sheet 2 from Single excel file and
The difference in two Sheets is update in Sheet 3

‘Initially go to “Tools -> References”.  Select “Microsoft Scripting Runtime” for activating File system ‘object.


Dim x(100, 100), y(100, 100) As Variant

Dim m, n, p, q As Variant

Dim db As New FileSystemObject

Sub Main()

'Declare "a" and "b" as object

Dim a, b As Object

'Create Excel application and set to variable "a"

Set a = CreateObject("excel.application")

'Open the Sheet 1 from work book and set to variable "b"

Set b = a.Workbooks.Open("c:\num.xls").Sheets(1)

'Get the used range rows and columns
r = b.usedrange.rows.Count
c = b.usedrange.columns.Count

'Loop for getting cell by cell value

For i = 1 To r
For j = 1 To c

'Assign cell value to Array of  "x(i,j)"

x(i, j) = b.cells(i, j).Value
Next
Next

'Open the Sheet 2 from work book and set to variable "b"


Set b = a.Workbooks.Open("c:\num.xls").Sheets(2)
'Get the used range rows and columns

r = b.usedrange.rows.Count
c = b.usedrange.columns.Count

'Loop for getting cell by cell value

For k = 1 To r

For l = 1 To c


y(k, l) = b.cells(k, l).Value



Next

Next

'Open the Sheet 3 for writing

Set b = a.Workbooks.Open("c:\num.xls").Sheets(3)

'Create object for text file

Set fs = CreateObject("scripting.filesystemobject")

'Create text file to store the Error message

Set ws = fs.CreateTextFile("C:\log.txt", True)


‘Write the General Text

ws.WriteLine ("Note: Cell in the order (row : Col) ")

‘Write blank lines
ws.WriteBlankLines (2)

'Loop for writing the value in cell by cell

For m = 1 To r
For n = 1 To c


'Condition statement to check the string from sheet 1 and sheet 2 is same.  If it is not same write
'the difference in Sheet 3

If x(m, n) = y(m, n) Then
Else

'Write the difference in Sheet 3

b.cells(m, n).Value = m & ":" & n & "  " & "The difference is " & x(m, n) & "  " & y(m, n)

'Write the Error in Text file for reference

ws.WriteLine ("Error in cell " & m & ":" & n)
End If

Next
Next


'Save the Active work book

b.Application.Activeworkbook.Save

'Close the Active work book

b.Application.Activeworkbook.Close

'Close the Text file

ws.Close


End Sub
'End Script


VB Script Built-in functions

VB Script Built-in functions


1) Asc Function


Dim Val
val=”A”
Msgbox Asc(val) ’65
Msgbox Asc(“Z”) ’90
Msgbox Asc(“a”) ’97
Msgbox Asc(“z”) ’122
Msgbox Asc(1) ’49
Msgbox Asc(“*”) ’42

Msgbox Asc(“America”) ’65

2) Chr Function

Dim Val
val=65
Msgbox Chr(val) ‘A
Msgbox Chr(90) ‘Z
Msgbox Chr(97) ‘a
Msgbox Chr(122) ‘z
Msgbox Chr(49) ’1
Msgbox Chr(42) ‘*

3) Abs Function

Dim Val
val=65.45
Msgbox Abs(val) ’65.45

val=65.55
Msgbox Abs(val) ’65.55

val=-65.55
Msgbox Abs(val) ’65.55

4) Round Function

Dim Val
val=65.45
Msgbox Round(val) ’65

val=65.55
Msgbox Round(val) ’66

val=-65.55
Msgbox Round(val) ‘-66
val=65.50
Msgbox Round(val) ’66

5) Array Function

Dim x
x=Array(“Hyderabad”, “Chennai”,”Deldhi”)
Msgbox x(0)
Msgbox x(1)
Msgbox x(2)

x=Array(100,200,300)
Msgbox x(0)
Msgbox x(1)
Msgbox x(2)

x=Array(#10-10-10#, #10/10/10#,#10/10/2010#,#Sep-10-10#)
Msgbox x(0)
Msgbox x(1)
Msgbox x(2)
Msgbox x(3)

x=Array(“Hyderabad”, 100,#10/10/2010#)
Msgbox x(0)
Msgbox x(1)
Msgbox x(2)

6) IsArray Function

Dim a,b,c(3),d(),e(2,3)
Msgbox IsArray(a) ‘False
Msgbox IsArray(b) ‘False
Msgbox IsArray(c) ‘True
Msgbox IsArray(d) ‘True
Msgbox IsArray(e) ‘True

a=Array(100,200,300)
Msgbox IsArray(a) ‘True
b=Split(“VB Script Language”,” “)
Msgbox IsArray(b) ‘True

Msgbox b(0)
Msgbox b(1)
Msgbox b(2)

7) IsDate Function

Dim val
val=”Hyderabad”
Msgbox IsDate(val) ‘False

val=100
Msgbox IsDate(val) ‘False

val=100.45
Msgbox IsDate(val) ‘False

val=#10-10-10#
Msgbox IsDate(val) ‘True

val=#10/10/10#
Msgbox IsDate(val) ‘True

val=#10-10-2010#
Msgbox IsDate(val) ‘True

val=#October-10-10#
Msgbox IsDate(val) ‘True

  Date Function

Dim myDate
myDate=Date
Msgbox myDate

9) Time Function

Dim myTime
myTime=Time
Msgbox myTime

10) Now Function

Dim myDay
myDay=Now
Msgbox myDay

myDay=Date & Time
Msgbox myDay

myDay=Time & Date
Msgbox myDay

11) Len Function

Dim val
val=”Hyderabad”
Msgbox Len(val) ’9

Msgbox Len(100) ’3

Msgbox Len(“@#$%^”) ’5

Msgbox Len(#10-10-2010#) ’10

Msgbox Len(#10-10-10#) ’10

Msgbox Len(#Sep-10-2010#) ’9

Msgbox Len(#Nov-10-2010#) ’10

Msgbox Len(Hyderabad) ’0

12) Left Function

Dim val
val=”Hyderabad”
Msgbox Left(val,3) ‘Hyd

Msgbox Left(100,2) ’10

Msgbox Left(#10-10-10#,5) ’10/10

Msgbox Left(“#10-10-10#”,3) ‘#10
—————–
Example:
Model 1:
Read a Mobile Number and verify the Series
‘Val should be Numeric
‘Val should contain 10 digits
‘If series is either “92478? or “92471 then display Tata Indicom Number
‘If series is either “98490? or “98480 then display AirTel Number

Dim val, val_Length, val_Numeric, val_Series
val=InputBox(“Enter a Mobile Number”)
val_Numeric=IsNumeric(val)
val_Length=Len(val)
val_Series=Left(val,5)

If val_Numeric=True and  val_Length=10 and val_Series=92478 Or  val_Series=92471  Then
Msgbox “It is a Tata Indicom Number”
ElseIf val_Numeric=True and  val_Length=10 and val_Series=98490 Or  val_Series=98480   Then
Msgbox “It is an Air Tel  Number”
Else
Msgbox “Invalid Data”
End If
—————————-
2nd Model:
‘Read a Mobile Number and verify the Series
‘Val should be Numeric
‘Val should contain 10 digits
‘If series is either “92478? or “92471 then display Tata Indicom Number
‘If series is either “98490? or “98480 then display AirTel Number

Dim val, val_Length, val_Numeric, val_Series
val=InputBox(“Enter a Mobile Number”)
val_Numeric=IsNumeric(val)
val_Length=Len(val)
val_Series=Left(val,5)
If  val_Numeric= True Then
If val_Length=10 Then
If val_Series=92478 Or  val_Series=92471  Then
Msgbox “It is a Tata Indicom Number”
ElseIf val_Series=98490 Or val_Series=98480  Then
Msgbox “It is an Air Tel  Number”
Else
Msgbox “Invalid Series”
End If

Else
Msgbox “It is not a 10 digit value”
End If
Else
Msgbox “It is not a Numeric Value”
End If

13) Right Function

Dim val
val=”Hyderabad”
Msgbox Right(val,3) ‘bad

Msgbox Right(100,2) ’00

Msgbox Right(#10-10-10#,5) ‘/2010

Msgbox Right(“#10-10-10#”,3) ’10#

val=”Hyderabad”
Msgbox Right(val,9) ‘Hyderabad

val=”Hyderabad”
Msgbox Right(val,20) ‘Hyderabad

val=”Hyderabad”
Msgbox Right(val,0) ‘Blank

val=”Hyderabad”
Msgbox Right(val) ‘Error (Length is Maditory)

14) Mid Function

Dim val
val=”Hyderabad”
Msgbox Mid(val,5,3) ‘rab

Msgbox Mid(100,2) ’00

Msgbox Mid(#10-10-10#,5) ’0/2010

Msgbox Mid(“#10-10-10#”,3,3) ’0-1

val=”Hyderabad”
Msgbox Mid(val,9) ‘d

val=”Hyderabad”
Msgbox Mid(val,20) ‘Blank

val=”Hyderabad”
Msgbox Mid(val,0) ‘Error

val=”Hyderabad”
Msgbox Mid(val) ‘Error
————-
Ex:
Price=”$100.45?
Units=”5?
Total=Units*Price
Msgbox Total

Price=”Rs100.45?
Price=Mid(Price,3)
‘Price=Right(Price,6)
Units=”5?
Total=Units*Price
Msgbox Total

15) DateDiff Function

Dim date1, date2

date1=#10-10-11#
date2=#10-10-09#
Msgbox DateDiff(“d”,date1,date2) &” Days”

date1=#10-10-09#
date2=#10-10-11#

Msgbox DateDiff(“d”,date1,date2) &” Days”

Msgbox DateDiff(“m”,date1,date2) &” Months”

Msgbox DateDiff(“yyyy”,date1,date2) &” Years”

Msgbox DateDiff(“w”,date1,date2) &” Weeks”

Msgbox DateDiff(“h”,date1,date2) &” Hours”

Msgbox DateDiff(“n”,date1,date2) &” Minutes”

Msgbox DateDiff(“s”,date1,date2) &” Seconds”

Msgbox DateDiff(“q”,date1,date2) &” Quarters”

16) Timer Function

Start_Transaction=Timer
SystemUtil.Run “C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”
Dialog(“Login”).Move 356,281
Dialog(“Login”).WinEdit(“Agent Name:”).Set “Thirupathi”
Dialog(“Login”).WinEdit(“Password:”).SetSecure “4cad3fd62c9fe96eebb24fc6c977a8a1e4fd28f4?
Dialog(“Login”).WinButton(“OK”).Click
Window(“Flight Reservation”).Activate
End_Transaction=Timer
Transaction_Time=End_Transaction-Start_Transaction
Msgbox Transaction_Time

17) StrComp Function

Dim str1, str2
str1=”HYDERABAD”
str2=”hyderabad”
Msgbox strComp(str1,str2) ‘-1 (str1<str2)

Msgbox strComp(str1,str2,0) ‘-1 (str1<str2) **0 is Compare mode for Binary

Msgbox strComp(str1,str2,1) ’0(str1<str2) **1 is Compare mode for Textual

str1=”hyd”
str2=”Hyderabad”
Msgbox strComp(str1,str2) ’1(str1<str2)

18) LCase Function

Dim Val
Val=”HYDERABAD”
Msgbox Lcase(val) ‘hyderabad

Val=”HyderabaD”
Msgbox Lcase(val) ‘hyderabad

Val=”hyderabad”
Msgbox Lcase(val) ‘hyderabad

Val=100
Msgbox Lcase(val) ’100

Val=”HYDERA100?
Msgbox Lcase(val) ‘hydera100

Val=”HYDER@#*”
Msgbox Lcase(val) ‘hyder@#*

19) UCase Function

Dim Val
Val=”HYDERABAD”
Msgbox UCase(val) ‘HYDERABAD

Val=”HyderabaD”
Msgbox UCase(val) ‘HYDERABAD

Val=”hyderabad”
Msgbox UCase(val) ‘HYDERABAD

Val=100
Msgbox UCase(val) ’100

Val=”HYDERA100?
Msgbox UCase(val) ‘HYDERA100

Val=”HYDER@#*”
Msgbox UCase(val) ‘HYDER@#*

20) Trim Function

21) RTrim Function

22) LTrim Function

Dim val
val=”                     VB Script                            ”
Msgbox val
Msgbox Trim(val)

val=”                     VB Script                            ”
Msgbox val
Msgbox RTrim(val)
val=”                     VB Script                            ”
Msgbox val
Msgbox LTrim(val)

23) CreateObject Function

Dim objFso
Msgbox VarType(objFso) ’0 for Empty
‘Creating an Automation Object in FileSystem Class, that can be used to perform File System Operations
Set objFso=CreateObject(“Scripting.FileSystemObject”)
Msgbox VarType(objFso) ’9 for Automation Object

Dim objExcel
‘Creating an Automation Object in Excel Class, that can be used to perform Spread sheet(Excel file)  Operations
Set objExcel=CreateObject(“Excel.Application”)

Dim objWord
‘Creating an Automation Object in Word Class, that can be used to perform Word Document Operations
Set objWord=CreateObject(“Word.Application”)

Dim objCon
‘Creating an Automation Object in Database Connection Class, that can be used to Connect to various databases
Set objCon=CreateObject(“Adodb.Connection”)

Dim objRs
‘Creating an Automation Object in Database RecordSet Class, that can be used to perform Operations on Database Tables(Records)
Set objRs=CreateObject(“Adodb.RecordSet”)

Dim objCom
‘Creating an Automation Object in Database CommandClass, that can be used to perform Maniplations on Databases
Set objCom=CreateObject(“Adodb.Command”)

Dim objDict
‘Creating an Automation Object in Dictionary class, that can be used to store “Key”, “Value” Pairs
Set objDict=CreateObject(“Scripting.Dictionary”)

24) IsEmpty Function


Dim x,y

x=100

Msgbox IsEmpty(x) ‘False

Msgbox IsEmpty(y) ‘True

y=”abcd”

Msgbox IsEmpty(y) ‘False


y=0

Msgbox IsEmpty(y) ‘False


y=Empty

Msgbox IsEmpty(y) ‘True

25) Cdbl Function


Dim val

val=”100.45?

Msgbox VarType(val) ’8 for String


val=Cdbl(val)

Msgbox VarType(val) ’5 for Double


26) CInt Function

Dim val

val=”100?

Msgbox VarType(val) ’8 for String


val=CInt (val)

Msgbox VarType(val) ’2 for Integer


val=”100.45?

Msgbox VarType(val) ’8 for String

Msgbox val


val=CInt (val)

Msgbox VarType(val) ’2 for Integer

Msgbox val


27) VarType Function


Dim val, x

val=”Hyderabad”

Msgbox VarType(val) ’8 for String


val=”100?

Msgbox VarType(val) ’8 for String


val=”100.456?

Msgbox VarType(val) ’8 for String


val=100

Msgbox VarType(val) ’2 for Integer


val=100.456

Msgbox VarType(val) ’5 for Double


Msgbox VarType(x) ’0 for Uninitialized


Msgbox VarType(#10/10/2010#) ’7 for Date format


Set x=CreateObject(“Scripting.FileSystemObject”)

Msgbox VarType(x) ’9 for Automation Object

An Introduction to Quality Center

An Introduction to Quality Center

Quality Center is a test management tool from HP (takeover from Mercury Interactive in 2007)

QC derived from TestDirector tool and developed in J2EE technology and backend database is MS SQL server

TestDirector developed in C++ technology default database is MS Access.

TestDirector has single cluster support where as QualityCenter has multi cluster support.

Quality Center is a web based test management solution; it supports standalone, Intranet and Internet environments.

Quality Center is available for both Windows and UNIX environments (QualityCenter for Windows and QualityCenter for UNIX)

Quality Center supports various activities like:

a) Requirement management

b) Test Design ( manual test cases as well as automated tests)

c) Test execution

d) Defect Management

e) Traceability among requirements, test cases and defects

f) Integrating with other tools like WinRunner, QTP and LoadRunner

Quality Center doesn’t have API as like QTP and LoadRunner

Quality Center has 2 Interfaces

I) Site Administration

II) Quality Center

Site Administration

It is administration area; here we can do below tasks:

a) Creating Domains

b) Deleting Domains

c) Creating a Project under a Domain

d) Deleting Projects

e) Creating Users

f) Editing User profiles

g) Deleting Users

h) Assigning users to a Project

i) Tracking a project’s status

Quality Center

It has four important modules

a) Requirements

In this module we can create, edit and delete Requirements.

And we can map Requirements with Test cases

b) Test Plan

It is an area, used for creating Manual as well as automated tests using WinRunner or QTP or LoadRunner

c) Test Lab

In this module Tests (manual as well as automated) can be executed.

During automated tests execution QualityCenter launches corresponding tool (WinRunner/QTP/LoadRunner) and that tool executes tests.

d) Defects

In this module testers can post defects and get status of their defects.

Note: QualityCenter can be used by Testers, Test Leads, Test Manager and Developers.

Quality Center Version history:

1st version QC 8.0

8.2

8.2 SP1

9.0 (in 2006)

9.2 (in 2007)

9.5 (in 2008)

10.0 (in 2009)
11.0 ( in 2010)

I) Exporting QTP Tests (From File System) to Quality Center Project

Steps:

    1) Create a folder in 'Test Plan' (QC) for Importing Tests

    2) Connect to Quality Center Project from QTP
        File menu-->Quality Center Connection-->Enter QC Server Url
        -->Enter User name & Password--> connect to Project
  
    3) Open a Test in QTP Test pane and Select Save As Option in File menu
    4) Select QC Test Plan and Save

--------------------------------------------------------
II) Exporting Tests from Quality Center Project to QTP (File System)

    1) Launch QC and Connect to the Project by Providing User Id & Password

    2) Select 'Test Plan' and selects an Automated test & Launch QTP

    3) Save As, Select 'File System' and Save

-------------------------------------------------------------------
III) Exporing Manual Requirements/Tests/Defects from File System (Using Excel/Word) to QC Project:

Pre-Requasites:

Download & Install Excel/Word Add in, then 'Export to Quality Center' Option will be available in Excel sheet 'Tools Menu.


Steps:

    1) Open Test case file (Excel)
    2) Tools menu ->Select 'Export to Quality Center' option
    3) Enter QC server Url and Click Next
    4) Enter User Name & Password and Click Next
    5) Select Domain & Project and Click Next
    6) select type of Data (Requirements/Tests/defects) and Click Next
    7) Enter map name and Click Next
    8) Map QC Fields to corresponding Excel Columns and Click Next
    9) Click Finish

Loading...