Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Thursday, 21 May 2015

What is the difference between QTP and UFT ?

HP Unified Functional Testing (UFT) is a new tool released in December of 2012 that integrates two of HP Testing products in a common IDE.It provides a power full testing framework for GUI and API testing:
  • HP Service Test
  • HP QuickTest Professional
HP Unified Functional Testing has enhanced and brand new functionalities that are not available in previous versions of HP Service Test or HP QuickTest Professional.
Some important considerations.
  • HP Unified Functional Testing offers integration with Perfecto Mobile in order to perform Mobile Testing.
  • HP Unified Functional Testing offers new Add-ins for GUI testing as such as: QT and Flex.
  • HP Unified Functional Testing is not considered to be newer version of either QuickTest Professional or ServiceTest.
  • Many of the knowledge base articles available for HP QuickTest Professional 10, 11 and HP Service Test 11.20 can be applied to HP Unified Functional Testing product.
  • Licenses for QTP or ST will work for UFT, but they can restrict some features. 
  • If you just need API Testing, you can use HP Service Test Standalone, however this option it’s not available for GUI testing.

Monday, 18 May 2015

Date & Time Functions in Vb-Script

List of Date Functions available in vb-script:
  1. Date
  2. Time
  3. Now
  4. Month
  5. MonthName
  6. Weekday
  7. Weekdayname
  8. Year
  9. Hour
  10. Minute
  11. Second
  12. Dateadd
  13. DateDiff
Uses of Date Functions: Assume that you are automating the application in which one of the screen date field accepts the different formats or need to add required days/months before entering the value in the date field. One more issue with day and month inputs when valid format was MM or DD. If we read the month and day from the system it returns a single digit month or day, but the application does not accept a month 6 (June) instead requires 06. In this kind of situations we require this date functions. 

Now : Returns the current system date and time.
Sysdate = Now
msgbox Sysdate
Result: UFT shows current system date and time in a dialog box

Date : Returns the current system date.
Mydate = Date
msgbox Mydate


Result: UFT shows current system date  in a dialog box

Day : Returns the current day from the system date.
Sysdate = Now
MyDay = Day (Sysdate)
msgbox MyDay


Result: UFT shows current day from the system date in a dialog box.

Example-1:

MyDay=Day(“January 122009”)
Msgbox MyDay


Output: 12

WeekDay : Returns the weekday from the given date.

Sysdate=Now
MyWeekDay=WeekDay(Sysdate)
msgbox MyWeekDay

Result: Returns(it returns the integer)  the weekday from the given date. 

Note: Sunday – 1, Monday – 2,Tuesday–3, Wednesday – 4, Thursday – 5, Friday – 6, Saturday – 7. 

Example:

MyDate=#January 12, 2009#      'Assgin a date
MyWeekDay=WeekDay(MyDate)
Msgbox  MyWeekDay

Output: 1 for Sunday, 2 for Monday, …so on

WeekDayName: Returns the weekday name for the specified day of the week.

Sysdate=Now
MyWeekDay=WeekDay(Sysdate)
Msgbox MyWeekDay
MyWeekDayName=WeekDayName(MyWeekDay)
msgbox MyWeekDayName

Result: Returns the weekday name for the specified day of the week.

Syntax: WeekdayName(weekday[,abbreviate[,firstdayofweek]])

Weekday: it Required the number of the weekday.
Abbreviate: it is an Optional. it gives Boolean value that indicates if the weekday name is to be abbreviated.
Firstdayofweek: it is an optional. it Specifies the first day of the week, it means that Firstdayofweek(Optional) has values like 0,1, 2... vb Use System DayOfWeek, 1 for Sunday, 2 for Monday and so on.

Msgbox(WeekdayName(4))
Output: Wednesday

Msgbox(WeekdayName(weekday(Date)))
Output: Sunday(obviously if today is Sunday)

Year: Returns the current year from the system date.
Sysdate = Now
MyYear = Year(Sysdate)
msgbox MyYear

Result: UFT shows current year from the system date in a dialog box.

Example:
MyDate=#January 12, 2009#             'Assign a date
MyYear=Year(MyDate)
Msgbox MyYear

Output: 2009

Month: Returns the current month from the system date.
Sysdate = Now
MyMonth = Month (Sysdate)
msgbox MyMonth

Result: UFT shows current month from the system date in a dialog box.

Example:

MyYear=Month(Now)
Msgbox MyYear


Output: 1 for January

MonthName: The MonthName function returns a string indicating the specified month.

Syntax: MonthName(month[, abbreviate])

Msgbox(MonthName(9))
Output:September

Month: it Required, and it specifies the number of the month(January is 1, februry is 2 etc)
Abbreviate: it is an optional. A Boolean value indicates that if the month name is to be abbreviated. Default is False.

DateAdd: it returns a date after adding a specified time interval.


Syntax: DateAdd(interval, number, date)


Msgbox(DateAdd("m"1"31-Mar-09"))
Output: 4/30/2009

Msgbox(DateAdd("m",-1,"31-Mar-09"))
Output:2/28/2009

Note: Interval can be YYYY-Year, q-Quarter, m-Month, h-hour, n-Minute

DateDiff: The DateDiff function returns the number of intervals between two dates.


Syntax: DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

Msgbox(DateDiff("m",Date"12/31/2009"))
or
Msgbox(DateDiff("m",03/14/2009"12/31/2009"))
Output:9

Note: Interval can be YYYY-Year, q-Quarter, m-Month, h-hour, n-Minute

Firstdayofweek(Optional): it has values like 0 for vbUseSystemDayOfWeek, 1 for vbSunday, 2 for vbMonday so on
FirstWeekofyear(optional):  0 for vaUseSystem, 1 for vbFirstJan 1, i.e Start with the week in which January 1 occurs(default), 2 for vbFirstFourDays i.e Start with the week that has at least four days in the new year, 3 for vbFirstFullWeek i.e Start with the first full of the new year.

DatePart: DatePart function returns the specified part of a given date. 

Syntax: DatePart(interval, date[,firstdayof week[,firstweekofyear]])

Msgbox(DatePart("d"Date))
Result : Returns the specified part of a given date
Or
Msgbox(DatePart("d""3/14/2009"))

Example:
Mypart = DatePart("d",now)msgbox Mypart       'Here getting the day part of the current date

Result : Returns the specified part of a given date

Note:Interval can be YYYY- Year, q-Quarter,m-month ,d-day


DateSerial: The dateserial returns a Date value representing a specified year, month, and day, with the time information set to midnight(00:00:00)

Syntax: DateSerial(Year, month, day)


Msgbox(DateSerial(2009,11,29))
Output: 11/29/2009

Msgbox(DateSerial(2009-9,9-2,1-1))
Output: 6/30/2000

DateValue: The DateValue function returns a type Date.

Syntax: DateValue(date)

Msgbox(DateValue("31-jan-09"))
Ouiput:1/31/2009

IsDate:  IsDate returns True if the expression is a date or can be converted to a valid date, Otherwise it  returns False.

Syntax: IsDate(Date)


MyDate= "January 12, 2009"
YesDate=#01/12/2009#
NoDate="Yes Boss"
MyCheck=IsDate(MyDate) 'Returns True
MyCheck=IsDate(YesDate) 'Returns True
MyCheck=IsDate(NoDate) 'Returns False

CDate:  The CDate function converts a valid date and time expression to type Date. Use the CDate function to determine if date can be converted to a date or time. The CDate function uses local setting to determine if a string can be converted to a date.

The  following example example uses the CDate function to convert a string to a date.

X="January 12, 2009"
If IsDate(x) then
   Msgbox (CDate(x))
End if
Output: 1/12/2009

Timer Functions

Timer:  The Timer function returns the number of seconds that have passed since midnight(12:00:00 AM).

Msgbox(Timer)
Output:  86296.13 at 11:58:16 PM

Minute : Return current minutes from the system date.

Sysdate = Now
MyMinute = Minute (Sysdate)
msgbox MyMinute
Result: UFT shows current minutes from the system date in a dialog box.

Second : Return current seconds from the system date.

Sysdate = Now
MySecond = Second (Sysdate)
msgbox MySecond
Result: UFT shows current seconds from the system date in a dialog box

Hour : Return current hour from the system date.

Sysdate = Now
MyHour = Hour (Sysdate)
msgbox MyHour
Result: UFT shows current hour from the system date in a dialog box

Time : Returns the current system time.

Mytime = Time
msgbox Mytime
Result: UFT shows current system time in a dialog box

TimeSerial: The TimeSerial function returns the  time for a specific hour, minute, and second.


Syntax: TimeSerial(hour, minute, second)

Msgbox(TimeSerial(0,18,11))
Output: 12:18:11 AM

TimeValue: The TimeValue function converts  an argument into the variant of subtype Date.

Syntax: TimeValue(time)

Msgbox(TimeValue("3:23:59 PM"))
Output: 3:23:59 PM

Examples: 
MyTime=Now
MyHour=Hour(MyTime)
Msgbox MyHour
Output: 17 at 5’o clock

MyVar=Minute(Now)
Msgbox MyVar
Output: 34 at 5:34 PM

 MySec=Second(Now)
Msgbox MySec
Output: 51 at 5:34:1 PM

For example your application date object allows the format dd-mm-yyyy format only. How to handle this?

Sysdate = Now
Sysyear = Year(Sysdate) 'Year is in yyyy format so need of any changes
Sysmonth=Month(Sysdate)  'Here month can be one or two digits
Mm=Len(Sysmonth)         'getting the length of the string

If mm < 2 then
  Retmonth="0"&mm  'If the month is one digit then we can concatenate 0 to month
Else
   Retmonth=mm
End if
Sysday=Day(Sysdate)  'Here day can be one or two digits
dd=Len(Sysday)       'getting the length of the string

If dd < 2 then
   Retday="0"&dd  'If the day is one digit then we can concatenate 0 to day
Else
   Retday=dd
End if

'Now concatenate the strings to required format dd-mm-yyyy
reqFormat = Retday&"-"&Retmonth&"-"&SysYear
msgbox reqFormat


Vb-Script Functions

Left Function: Returns left side of string from a given string
Dim Val, x,y
Val="Hyderabad"
x=Left(Val,3)
Msgbox x

Output: Hyd

Val=100
x=Left(Val,1)
Msgbox x

Output: '1

Val="Hyderabad"
x=Left(Val,0)
Msgbox x

Output: Null

Val="Hyderabad"
x=Left(Val,12)
Msgbox x

Output: Hyderabad

Val=#10-10-10#
x=Left(Val,3)
Msgbox x

Output: 10/

Val="Hyderabad"
x=Left(Val)
Msgbox x

Output: 'Error (Lengnth is Manditory)

Right Function: This function returns the right side of the string from the given string
Dim AnyString, MyStr
AnyString = "Hello World" ' Define string.
MyStr = Right(AnyString, 1) ' Returns "d".
MyStr = Right(AnyString, 6) ' Returns " World".
MyStr = Right(AnyString, 20) ' Returns "Hello World".

Len Function: Returns the number of characters in a string or the number of bytes required to store a variable.
Dim Mystring
mystring=Len("G.C.Reddy")
msgbox mystring

Output: 9

Dim Mystring
Mystring=Inputbox("Enter a Value")
Mystring=Len(Mystring)

Msgbox Mystring

Mid Function: Returns a specified number of characters from a string.
Dim Val, x,y
Val="Hyderabad"
x=Mid(Val,3,4)
Msgbox x

Output:  dera

Val=100
x=Mid(Val,1)
Msgbox x

Output:  100

Val="Hyderabad"
x=Mid(Val,6,7)
Msgbox x

Output: abad

Val="Hyderabad"
x=Mid(Val,6,1)

Msgbox x

Output: a

Val="Hyderabad"
x=Mid(Val,6,0)

Msgbox x

Output: Null

Val="Hyderabad"
x=Mid(Val,12)
Msgbox x

Output: Null

Val=#10-10-10#
x=Mid(Val,3,3)
Msgbox x

Output: /10

Val=#2010-10-10#
x=Mid(Val,5)
Msgbox x

Output: /2010

Val="Hyderabad"
x=Mid(Val)
Msgbox x

Output: Error

Timer Function: Returns the number of seconds that have elapsed since 12:00 AM (midnight).
Function myTime(N)
Dim StartTime, EndTime
StartTime = Timer
For I = 1 To N
Next
EndTime = Timer
myTime= EndTime - StartTime
msgbox myTime
End Function

Call myTime(2000)

isNumeric Function : It Returns True/False  Result 
Dim MyVar, MyCheck
MyVar = 53
MyCheck = IsNumeric(MyVar)
msgbox MyCheck

MyVar = "459.95"
MyCheck = IsNumeric(MyVar)
msgbox MyCheck

MyVar = "45 Help"
MyCheck = IsNumeric(MyVar)
msgbox MyCheck
RoundReturns a number rounded to a specified number of decimal places.
Dim num
num=172.499
num=Round(num)
msgbox num

OutPut: 172

StrReverse: It returns reverse value of the given sring
 x=strreverse ("dabaraedyh")
msgbox x

Output: hydearabad

strComp:It compares two strings based on ASCII Values and Returens -1 (1st less than 2nd ), 0 (Equal) and 1 (1st greater than 2nd)
Dim x, y
x="cd": y="bcd"
comp=strcomp(x,y)
msgbox comp

Output: 1
Replace: It replace a sub string with given value (another sub string)

 mystring=Replace("kb script""k","v")
msgbox mystring

Output: vb script


Abs Function: Returns the absolute value of a number.
Dim num
num=abs(-50.33)
msgbox num

Output: 50.33


Array Function: Returns a variant containing an Array
Dim A
A=Array("hyderabad","chennai","mumbai")
msgbox A(0)
ReDim A(5)
A(4)="nellore"
msgbox A(4)

Output 1: hyderabad; Output 2: nellore

Asc Function: Returns the ANSI character code corresponding to the first letter in a string.
Dim num
num=Asc("A")
msgbox num

OutPut:  65 

Chr Function: Returns the character associated with the specified ANSI character code.
Dim char
Char=Chr(65)
msgbox char

OutPut: A

CInt Function:Returns an expression that has been converted to a Variant of subtype Integer.
Dim num
num=123.45
myInt=CInt(num)
msgbox MyInt

Output: 123

6) Date Function: Returns the Current System Date.
Dim mydate
mydate=Date
msgbox mydate

Output: We get our system current date

7) Day Function: 
Dim myday
myday=Day("17,December,2009")
msgbox myday

Output: 17

Dim myday
mydate=date
myday=Day(Mydate)
msgbox myday

Output: We get current date

DateDiff Function: Returns the number of intervals between two dates.
Dim Date1, Date2, x
Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("yyyy", Date1, Date2)
Msgbox x 'Differnce in Years

Output:2

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("q", Date1, Date2)
Msgbox x 'Differnce in Quarters

Output: 8

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("m", Date1, Date2)
Msgbox x 'Differnce in Months

Output: 24

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("w", Date1, Date2)
Msgbox x 'Differnce in weeks

Output: 104

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("d", Date1, Date2)
Msgbox x 'Differnce in days

Output: 730

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("h", Date1, Date2)
Msgbox x 'Differnce in Hours

Output:17520

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("n", Date1, Date2)
Msgbox x 'Differnce in Minutes

Output: 1051200

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("s", Date1, Date2)
Msgbox x 'Differnce in Seconds

Output: 63072000

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("y", Date1, Date2)
Msgbox x  'Differnce in day of years

Output: 730

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff("a", Date1, Date2)
Msgbox x 'Error

Date1=#10-10-09#
Date2=#10-10-11#
x=DateDiff(Date1, Date2)
Msgbox x 'Error

Hour Function: Returns a whole number between 0 and 23, inclusive, representing the hour of the day.
Dim mytime, Myhour
mytime=Now
myhour=hour(mytime)

msgbox myhour

Join Function: Returns a string created by joining a number of substrings contained in an array.
Dim mystring, myarray(3)
myarray(0)="Chandra "
myarray(1)="Mohan "
myarray(2)="Reddy"
mystring=Join(MyArray)
msgbox mystring

Output: Chandra Mohan Reddy

Eval Function: Evaluates an expression and returns the result.

Time Function: Returns a Variant of subtype Date indicating the current system time.
Dim mytime
mytime=Time
msgbox mytime

Output: we get current time of your system

VarType Function: Returns a value indicating the subtype of a variable.
Dim x,y
x=100
y=VarType(x)
Msgbox y

Output: 2 (Integer)
x="Hyderabad"
y=VarType(x)
Msgbox y

Output: '8 (String)
x=#10-10-10#
y=VarType(x)
Msgbox y

Output: 7(Date format)
x=100.56
y=VarType(x)
Msgbox y

Output:  5(Double)
y=VarType(a)
Msgbox y
Output: '0 (Empty)

Set x =CreateObject("Scripting.FileSystemObject")
y=VarType(x)
Msgbox y

Output: 9(Automation Object)

Inputbox Function: Displays a prompt in a dialog box, waits for the user to input text or click a button, and returns the contents of the text box.

Dim Input
Input = InputBox("Enter your name")
MsgBox ("You entered: " & Input)

Input:UFT
Output: You entered UFT

Msgbox Function:Displays a message in a dialog box, waits for the user to click a button, and returns a value indicating which button the user clicked.

Dim MyVar
MyVar = MsgBox ("Hello World!"65"MsgBox Example")

Output: Hello World!

CreateObject:creates and returns reference of the filesytemobject to an Automation object. It can be used for performing operations on computer file system

Set objFso=createobject ("Scripting.FileSystemObject")

'creates and returns reference of  the Excel object to an Automation object. It can be used for performing operations on Spreed sheet (Ms-Excel files)

Set objExcel = CreateObject("Excel.Application")

'creates and returns reference of  the Word Object to an Automation object. It can be used for performing operations on Ms-Word documents

Set objWord = CreateObject("Word.Application")

'creates and returns reference of  the Database Connection to an Automation object. It can be used for Connecting, opening and Closing databases

Set objConnection = CreateObject("ADODB.Connection")

'creates and returns reference of  the Database Recordset to an Automation object. It can be used for performing operations on database tables(Records)

Set objRecordSet = CreateObject("ADODB.Recordset")

'creates and returns reference of  the Ms-Power point object to an Automation object. It can be used for performing operations on Power point presentations

Set objPPT = CreateObject("PowerPoint.Application")

Set xmldoc = WScript.CreateObject("msxml2.domdocument")