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

Descriptive Programming in UFT : 10 Key points

1. Descriptive programming is describing the object properties in the code itself instead of defining an object in the object repository.

2. Descriptive programming has two flavors: 
 a.) Static DP
 b.) Dynamic DP

3. Static DP defines the object property in inline description in the Page tree structure as defined below:
''example 3.1) - In case all the object in the tree are defined as static DP
Browser("title:=Bing").Page("title:=Bing").WebEdit("name:=qb").Set "test automation"

''example 3.2) Multiple properties are used to uniquely identify an element,
 the properties are seperated by ,
Browser("title:=ng").Page("title:=ng").WebEdit("name:=qb", "type:=input").Set "test"


4. The structure of element in the page follows the tree structure as Browser --> Page --> WebElement.
We cannot define browser and page as descriptive programming, in case  last element in the tree(WebEdit, WebElement is defined from Object repository.

5. Dynamic description example is shown below:
Set objdescBR = description.Create
objdesc("title").value ="Google"
Set objdescPg = description.Create
objdescPg("title").value ="Google"
Set objdesc = description.Create
objdesc("micclass").value ="Link"
Set objLinks = Browser(objdescBR).Page(objdescPg).childobjects(objDesc)
Msgbox objLinks.count

6. Dynamic description is useful to perform similar action on group of elements. e.g: get the text of all the links in the page.

7. Set objLinks = Browser(objdescBR).Page(objdescPg).childobjects(objDesc) returns list of elements. This can be a list of links in the page or multiple checkbox
in the page.

8. We can access each element of group of element using objLinks(index) as shown below:
For i=0 to objLinks.count -1 to Step 1
 objLinks(i).GetRoProperty("name")
Next

9. Descriptive programming is very useful in case of:

9.1 - Common element definition used across a set of pages in the application. e.g: Canel, OK, New button
9.2 - In case of DP programming used in function libraries, the objects are defined in Function library and can be used in multiple tests.
9.3 - Performing same action with multiple elements with similar properties.
9.4 - Maintaining OR can be complex and OR size may grow considerably in the application. 
9.5 - Application is not ready. 
9.6 - Keyword driven framework.
9.7 - A good approach is to use a mix of Object Repository and Object repository and xpath definition.

10. Regular expression can be used together with Descriptive programming, which can again be part 
of another article 10 things to know, regular expression with descriptive programming.

Environment variable in UFT : 10 Key points

1. Definition - Environment variables are variables used across QTP Scripts/ all actions in a script/recovery scenario/function libraries in a UFT script.
Understand them as global variables for UFT Test Scripts.

2. Types of Environment Variables:
Environment variables are of 2 types: 
a. Built in Variables
b. User Defined Variables

3. Built -in variables are defined in QTP and can provide information on the QTP scripts and the operating system.

4. User Defined variables are again be divided into two types: 
       a. User Defined - Internal - defined at test level by adding a new environment parameter.
       b. User Defined - External - imported for an external xml file with parameters and values for parameters defined in the external file.




5. Steps to add user defined environment variables:

a.) In the test in which environment variable are to be added, Go to file -> Settings -> Environment.
b.) In variable type, select user defined. 
c.) Click on + icon, and add a new parameter with name and value.

6. To import from external file, check checkbox to load from external file and provide the path of the external file.

7. Environment variable for external file can be imported through code as shown below:

fileName = Environment.ExternalFileName

if (fileName = "") Then

    Environment.LoadFromFile("C:\testEnv.xml")

End If

8. Access and update environment variable in the script:


''Acessing an environment variable:

Testval =  Environment.Value("testing")

''Updating an user defined variable

Environment.Value("testing") = "testing2"

9. Example of environment variable xml file


<Environment>
 <Variable>
  <Name>Environment1</Name>
  <Value>ValueA</Value>
 </Variable>
 <Variable>
  <Name>Variable2</Name>
  <Value>ValueB</Value>
 </Variable>
</Environment>


10. Useful Reference: 


http://gareddy.blogspot.in/2010/12/qtp-environment-variables.html

http://qaautomationqtp.blogspot.in/2013/05/environment-variables-in-qtp.html

Summary

environment variable summary


Batch file to delete all files from folder

Below code shows how to delete all files from a folder matching the specific criteria.

FORFILES /p "E:\test\Result" /s /m *.* /D -5 /C "cmd /c del *.* /F /Q"

The above code will delete all files in the folder "E:\test\Result" recursively in the sub folder matching all the files which are older than 5 days.

No pop-up and prompt will be displayed and file will be deleted