Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Understanding Date time function: Using VBScript in QTP

Below are some of the useful function for working with date/time in vb script. We will use the functions and illustrate where the functions can be used.


1. Date - This returns the current date of the system.


2. Now - This returns the current Date and time of the system.So now contains time part as well as date part while date function returns only date.


3. Time - This returns the current time of the system. So in terms of relation between date , time, and now function 


Now = date + time

4. Year, Month, Day, hour, minute, second - These functions return year, month,day,hour,minute,second part for the expression.


example : day(now) or  minute(now)

Above functions discussed above are useful for timestamp , and also for generating a unique number based on the function used.


5. Timer - Timer returns the number of seconds from 12:00a.m. This function is very useful for evaluating time spent in performing an activity by taking timer at the start and end of the activity and subtracting the time between two.


6. DatePart - returns specific part of the date .Possible values or part of date , that can be extracted as shown below:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week of year
  • h - Hour
  • n - Minute
  • s - Second
Syntax of the function is : DatePart("m",d))where d is the date as "2013-06-09" and m will return the month of the date.

7. DateDiff - Returns the difference between two dates: 

Syntax : DateDiff(interval,date1,date2). Interval can be yyyy,q,m, y,d,.... as discussed earlier.


8. DateAdd - Add specified date to the date.

Syntax : DateAdd(interval,number,date)


VB Script functions to manipulate strings in QTP

We should know the useful vb script function to manipulate strings. In this post, we will discuss some of the vb script function to manipulate strings and how they can be used in codes:

1. Instr searches for a string within another another string and returns the location of occurrence of one string within another string.It returns the position of first occurrence of the string.This function is used if we need to verify if a particular text appears in a string.


Syntax : InStr([start,]string1,string2[,compare])


Example - Report and loop in case a particular text in not found in the string :

If (Instr(1, string1, string2)>0) Then
    Reporter.ReportEvent micpass , "string 2 is found in string 1","As expected"
Else
    Reporter.ReportEvent micfail , "string 2 is  found in string 1","string 2 is not found in string1"
End If

2. InstrRev is similar to instr and can be used for similar purposes, with only difference search starts from the end of string, although count returned is from start of string.


InStrRev(string1,string2[,start[,compare]])


3. Trim , lTrim, Rtrim removes characters from both left and right, only left and only right respectively blank spaces.


4. Left , Right, and Mid returns a specified character from left, right, and middle of the string. 


Mid(string,start[,length])

5. len returns number of characters in the string.


6. Split splits a string based on the delimiter in the function.


Example - How to find the total number of occurrence of a string in another string.By default, string2 has value space if not provided.

arrString = split(string1,string2)
totOccurence = ubound(arrString)

Example- Total number of words in a string.

arrString = split(string1)
totOccurence = ubound(arrString)




What are different activities in Testing Process

Testing Process includes following activities that should be followed sincerely for proper testing.



1. Test Planning


Before beginning with testing, we need to define test plan based on which we perform testing for the rest of testing life cycle. We should develop a test plan based on following key points to be considered in testing life cycle.

  • Test Objectives should be measurable, prioritized, and should be signed off between stakeholders before moving forward with test planning. Acceptance Criteria should also be defined during objective settings to validate if the test objective has been accompanied.
  • Test Matrix should be defined on how to test the test objectives and to validate all the requirements are covered in testing.
  • Test Schedule should be defined, how milestones in testing will be covered and timeframe in which milestones will be delivered
  • Budgeting and resources planing should be defined.
  • Testing material including environment ans software/availability should be defined.
  • Training required for testing should be defined.


2. Test Control Activities

Once Test plan is created and signed off by stakeholder, Activities in test plan should be compared with actual and any deviation from the projected plan should be reported to stakeholders as risk.


3. Test Analysis

In this phase, test objectives defined in test planning are converted into test scenarios and test cases.Below are the main task in this phase:

  • Reviewing the test artifacts like business requirements, design, and test objectives.
  • Identifying and prioritizing test scenarios and test cases based on business requirements.
  • Identification of test data for execution of test conditions
  • Test environment availability


4. Test implementation

Below are activities in test implementation

  • Developing and prioritizing test cases with test steps
  • Preparation of test data for execution of test scripts.
  • Environment set up for testing.
  • Development of automation test harness.
  • Preparation of test suites for regression, smoke testing, and execution of similar tests in batch.


5. Test Execution and Reporting

  • Execution of test scripts either manual or automated.
  • Reporting defects found during test script execution.
  • Regression testing and retesting of fixed defects. 
  • Reporting of test execution status to stakeholders.


6.  Exit criteria

  • Evaluating Testing status against the exit criteria specified in test planning.
  • Test Status should validate that all acceptance criteria are verified.

7. Test Closure Activities

  • Delivering all the planned test artifacts to the client. For e.g : Automated Test Scripts,test scripts, test data for further reuse.
  • Handover of artifacts and knowledge transfer to maintenance team
  • Analysis of lesson learnt during testing process.