Conversion Functions:
|
Asc(string):Returns the ANSI character code corresponding to the first letter in a string.
|
CInt(expression): Returns an expression that has been converted to a Variant of subtype Integer
|
CStr(expression): Returns an expression that has been converted to a Variant of subtype String
|
CDate(date):Returns an expression that has been converted to a Variant of subtype Date.
|
Date Functions:
|
Date:Returns the current system date.
|
DateAdd(interval, number, date):Returns a date to which a specified time interval has been added.
|
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]]):Returns the number of intervals between two dates.
|
DatePart(interval, date[, firstdayofweek[, firstweekofyear]]):Returns the specified part of a given date.
|
DateSerial(year, month, day):Returns a Variant of subtype Date for a specified year, month, and day.
|
Day(date):Returns a whole number between 1 and 31, inclusive, representing the day of the month
|
IsDate(expression):Returns a Boolean value indicating whether an expression can be converted to a date.
|
Now:Returns the current date and time according to the setting of your computer's system date and time.
|
Weekday(date, [firstdayofweek]):Returns a whole number representing the day of the week.
|
Year(date):Returns a whole number representing the year.
|
String Functions:
|
InStr([start, ]string1, string2[, compare]): Returns the position of the first occurrence of one string within another.
|
InStrRev(string1, string2[, start[, compare]]): Returns the position of an occurrence of one string within another, from the end of string.
|
Join(list[, delimiter]):Returns a string created by joining a number of substrings contained in an array.
|
LTrim(string),RTrim(string),Trim(string):Returns a copy of a string without leading spaces (LTrim), trailing spaces (RTrim),
or both leading and trailing spaces (Trim). |
Len(string | varname):Returns the number of characters in a string or the number of bytes required to store a variable.
|
Left(string, length): Returns a specified number of
|
characters from the left side of a string.
|
Mid(string, start[, length]):Returns a specified number of characters from a string.
|
Right(string, length): Returns a specified number of characters from the Right side of a string.
|
StrReverse(string1):Returns a string in which the character order of a specified string is reversed.
|
StrComp(string1, string2[, compare]):Returns a value indicating the result of a string comparison.
|
Split(expression[, delimiter[, count[, compare]]]):Returns a zero-based, one-dimensional array containing a specified number of substrings.
|
Space(number):Returns a string consisting of the specified number of spaces.
|
Friday, 13 December 2013
QTP Functions
Regular Expressions in QTP
Regular Expressions in QTP
Sometimes there might be situations where values of objects keep on varying and QTP may fail to recognize them or checkpoints might get failed as the expected and actual data are not matching. In such cases Regular expressions come into picture. It enables QTP to identify objects and text strings with varying values. Regular expressions can be used:
1. In identifying the property values of an object
2. In parametrization
3. For creation of checkpoints on objects with varying values
1. In identifying property values of an object:
In this concept, let’s see how to handle QTP when a value of an object is varied. Let’s walk through this section with a small example:
In this concept, let’s see how to handle QTP when a value of an object is varied. Let’s walk through this section with a small example:
Assume that you have to record a scenario of verifying the mails in a mail account. Open the mail with valid username and password. Now click on Inbox. When you have opened your mail account assume that there are 5 mails. So the inbox would be showing Inbox (5). When you click on that, the mails get displayed. Following would be the statement that gets generated when clicked on Inbox:
Browser(“Gmail”).Page(“Gmail”).Link(“Inbox(5)”).click
Now when the same script is run again, QTP fails at the same step as the number of mails in the inbox is 4. Or even more if some new mails have come. The script execution doesn’t get passed unless the total number of new mails is again 5. We make use of regular expression here as the value for the number of mails keeps varying.
For creating a regular expression, go to object repository from Resourcesà Object repository. Select the link object Inbox (5) from object list displayed in the left side.
Go to the object properties screen displayed in the right side of the screen. Select the property that has the value Inbox (5). Click on the configure icon that gets displayed there.
‘Value configuration Options’ dialog box gets displayed.
Check the Regular expressions check box. A dialog box gets raised asking the user whether to add a back slash before each special character in order to treat it literally. As we have special characters ‘(‘ and ‘)’ we need to click on Yes and QTP adds a slash character before both the Parenthesis characters.
If you want qtp script to be successful for 0-9 mails then give the following value in Constant edit box:
Inbox\([0-9]\)
For 0-99 mails
Inbox\([0-9][0-9]\)
For 0-999 mails
Inbox\([0-9][0-9][0-9]\)
Click on OK and close the object repository window. For first option QTP executes the scripts successfully if the Inbox has 0-9 mails. Second option executes successfully for 0-99 mails and third option for 0-999 mails.
2. In Parameterization:
In some cases, we need to parameterize the varying values in the script. In such cases we parameterize the values and use the regular expression in parameterized value i.e., in data table sheet where the value is present. Using the same example mentioned above lets discuss how can be regular expressions in parameterization process.
Select the link object Inbox (5) from object list displayed in the left side of Object repository.
Go to the object properties screen displayed in the right side of the screen. Select the property that has the value Inbox (5). Click on the configure icon that gets displayed there.
‘Value configuration Options’ dialog box gets displayed. Set the Parameter Radio button and select the location of data table (global/local). Enter a title for the column.Now check the Regular expressions checkbox in advanced configurations option. Click on Yes in the dialog box that gets displayed.
Click on OK and close the object repository window. If you want QTP script to be successful for 0-9 mails then give the following value in Data table sheet of QTP:
Inbox\([0-9]\)
For 0-99 mails
Inbox\([0-9][0-9]\)
For 0-999 mails
Inbox\([0-9][0-9][0-9]\)
For first option QTP executes the scripts successfully if the Inbox has 0-9 mails. Second option executes successfully for 0-99 mails and third option for 0-999 mails. Using this example, the values can be changed directly in the data table sheet.
3. For creation of checkpoints on objects with varying values
3. For creation of checkpoints on objects with varying values
Assume that you have to create a text check point on some text which gets varied continuously. In the same example mentioned above, you need to insert a text checkpoint on Inbox (5) which gets varied basing on the number of mails available in the inbox. When the checkpoint is created, it takes Inbox (5) as the expected value and when the same script is run again when there are 4 mails in the inbox, and then the checkpoint fails. To overcome such situations, regular expressions is used again.
Insert a checkpoint by selecting Insert-->Checkpoint-->Text Checkpoint. (Make sure that QTP is in recording mode)
Select the text on which you want to insert text checkpoint (i.e., Inbox (5)). Text checkpoint properties window gets opened.Make sure that the radio button is set to constant dialog box. Click on Constant Value options icon that gets displayed there.
‘Constant Value options’ dialog box gets displayed. Now check the regular expressions check box and Click on yes in the dialog box that gets displayed to treat ‘(‘ and ‘)’ as literal characters. Now in the same way as mentioned in the above two examples enter the data as per your requirement.
For 0-9 mails
Inbox\([0-9]\)
For 0-99 mails
Inbox\([0-9][0-9]\)
For 0-999 mails
Inbox\([0-9][0-9][0-9]\)
Click on OK and close the Text checkpoint properties window. For first option QTP checkpoint gets passed if the Inbox has 0-9 mails. Second option gets passed for 0-99 mails and third option for 0-999 mails.
Tuesday, 3 December 2013
QTP Driver Script
Actually we are using VBScript in most of the areas in QTP. But the Driver Script is the only QTP script, remaino all are VBscript files(.VBS).
Driver script is mainly useful to organize the Tests Exection and stores Test Logs in the specified file/folder.
Example:
adding sheets to runtime data table
datatable.AddSheet ("Module")
datatable.AddSheet ("Testcase")
datatable.AddSheet ("Teststep")
'Adding data sheets to runtime data table
Tcrowcount=datatable.GetSheet ("Testcase").getrowcount
For j=1 to Tcrowcount step 1
datatable.SetCurrentRow (j)
moduleid1=datatable.Value(4,"Testcase")
tcexe=datatable.Value(3,"Testcase")
If moduleid=moduleid1 and Ucase(tcexe)="Y" Then
TcId=datatable.Value(1,"Testcase")
Tsrowcount=datatable.GetSheet("Teststep").getrowcount
For k= 1 to Tsrowcount step 1
datatable.SetCurrentRow(k)
Tcid1=Datatable.Value(5,"Teststep")
If TcId= TcId1 Then
keyword= datatable.Value(3,"Teststep")
Select Case keyword
Case "ln"
res=Login()
datatable.Value(6,"Teststep")=res
Case "ca"
close_app
Case "op"
res=Openord()
datatable.Value(6,"Teststep")=res
End Select
End If
Next
End If
Next
End If
Next
datatable.ExportSheet "D:\Automation\Testlog\results.xls","Teststep"
Sample Initialization Script:
Initialization Script launches QTP Tool and Calls Driver Script, Driver Script execute Tests and Stores Results.
Finally Initialization Script Closes QTP tool
Option Explicit
Dim qtApp
set qtApp=createobject("QuickTest.Application")
qtApp.Launch
qtApp.Visible=True
qtApp.Open "D:\Automation\Testscripts\Driver"
qtApp.Test.Run
qtApp.Quit
Driver script is mainly useful to organize the Tests Exection and stores Test Logs in the specified file/folder.
Example:
adding sheets to runtime data table
datatable.AddSheet ("Module")
datatable.AddSheet ("Testcase")
datatable.AddSheet ("Teststep")
'Adding data sheets to runtime data table
Tcrowcount=datatable.GetSheet ("Testcase").getrowcount
For j=1 to Tcrowcount step 1
datatable.SetCurrentRow (j)
moduleid1=datatable.Value(4,"Testcase")
tcexe=datatable.Value(3,"Testcase")
If moduleid=moduleid1 and Ucase(tcexe)="Y" Then
TcId=datatable.Value(1,"Testcase")
Tsrowcount=datatable.GetSheet("Teststep").getrowcount
For k= 1 to Tsrowcount step 1
datatable.SetCurrentRow(k)
Tcid1=Datatable.Value(5,"Teststep")
If TcId= TcId1 Then
keyword= datatable.Value(3,"Teststep")
Select Case keyword
Case "ln"
res=Login()
datatable.Value(6,"Teststep")=res
Case "ca"
close_app
Case "op"
res=Openord()
datatable.Value(6,"Teststep")=res
End Select
End If
Next
End If
Next
End If
Next
datatable.ExportSheet "D:\Automation\Testlog\results.xls","Teststep"
Sample Initialization Script:
Initialization Script launches QTP Tool and Calls Driver Script, Driver Script execute Tests and Stores Results.
Finally Initialization Script Closes QTP tool
Option Explicit
Dim qtApp
set qtApp=createobject("QuickTest.Application")
qtApp.Launch
qtApp.Visible=True
qtApp.Open "D:\Automation\Testscripts\Driver"
qtApp.Test.Run
qtApp.Quit
Thursday, 28 November 2013
Sunday, 24 November 2013
Forward and Reverse Traceability Matrix.
Traceability matrix is a document that maps and traces user requirement with the test cases. Main motto to make sure all requirement are covered in test cases so while testing no functionality can be missed.
Traceability Matrix is used in entire software development life cycle phases:
- Risk Analysis phase
- Requirements Analysis and Specification phase
- Design Analysis and Specification phase
- Source Code Analysis, Unit Testing & Integration Testing phase
- Validation – System Testing, Functional Testing phase
Types of traceability matrix
1: forward traceability = Mapping of requirements to test cases. It ensures proper direction of the evolving product (that we are building the right product)
1: forward traceability = Mapping of requirements to test cases. It ensures proper direction of the evolving product (that we are building the right product)
Req. Capture -> Design Document -> Test Cases .Tracing each unique product requirement forward into the design that implements that requirement, the code that implements that design and the tests that validate that requirement and so on. The objective is to ensure that each requirement is implemented in the product and that each requirement is thoroughly tested.
2: Reverse or backward traceability = mapping of test cases to requirement.Used for to check the end product has met the requirements or not. Backwards traceability helps ensure that the evolving product remains on the correct track with regards to the original requirements (that we are building the product right). The objective is to ensure that we are not expanding the scope of the project by adding design elements, code, tests or other work products that are not called out in the requirements (i.e., “gold plating”).
Test Cases -> Design -> Req. Capture
3: Bi Directional traceability = Forward traceability+ backward traceability.
Test Cases -> Design -> Req. Capture
3: Bi Directional traceability = Forward traceability+ backward traceability.
Benefits of bi-directional requirements traceability include the ability to:
• Analyze the impact of a change
− All work products affected by a changed requirement
− All requirements affected by a change or defect in a work product
− All work products affected by a changed requirement
− All requirements affected by a change or defect in a work product
• Assess current status of the requirements and the project
− Identify missing requirements
− Identify missing requirements
− Identify gold plating or extras
Thursday, 21 November 2013
Boundary Value Analysis & Equivalence Class Partition
Boundary value analysis and
equivalence partitioning both are test case design strategies in black box
testing.
Equivalence Partitioning:
In this method the input domain data is divided into different
equivalence data classes. This method is typically used to
reduce the total number of test cases to a finite set of
testable test cases, still covering maximum requirements.
In short it is the process of
taking all possible test cases and placing them into classes. One test value is
picked from each class while testing.
E.g.: If
you are testing for an input box accepting numbers from 1 to 1000 then there is
no use in writing thousand test cases for all 1000 valid input numbers plus
other test cases for invalid data.
Using
equivalence partitioning method above test cases can be divided into three sets
of input data called as classes. Each test case is a representative of
respective class.
So in
above example we can divide our test cases into three equivalence classes of
some valid and invalid inputs.
Test cases for input box accepting numbers between 1 and 1000
using Equivalence Partitioning:
1) One input data class with all valid inputs. Pick a single value from range 1 to 1000 as a valid test case. If you select other values between 1 and 1000 then result is going to be same. So one test case for valid input data should be sufficient.
1) One input data class with all valid inputs. Pick a single value from range 1 to 1000 as a valid test case. If you select other values between 1 and 1000 then result is going to be same. So one test case for valid input data should be sufficient.
2) Input
data class with all values below lower limit. I.e. any value below 1, as a
invalid input data test case.
3) Input
data with any value greater than 1000 to represent third invalid input class.
So
using equivalence partitioning you have categorized all possible test cases
into three classes. Test cases with other values from any class should give you
the same result.
We
have selected one representative from every input class to design our test
cases. Test case values are selected in such a way that largest number of
attributes of equivalence class can be exercised.
Equivalence
partitioning uses fewest test cases to cover maximum requirements.
Boundary value analysis:
It’s widely recognized that input values at the extreme ends of
input domain cause more errors in system. More application errors
occur at the boundaries of
input domain. ‘Boundary value analysis’ testing technique is used to identify
errors at boundaries rather than finding those exist in center of input domain.
Boundary
value analysis is a next part of Equivalence partitioning for designing test
cases where test cases are selected at the edges of the equivalence classes.
Test cases for input box accepting numbers between 1 and 1000
using Boundary value analysis:
1) Test cases with test data exactly as the input boundaries of input domain i.e. values 1 and 1000 in our case.
1) Test cases with test data exactly as the input boundaries of input domain i.e. values 1 and 1000 in our case.
2) Test
data with values just below the extreme edges of input domains i.e. values 0
and 999.
Subscribe to:
Posts (Atom)