Académique Documents
Professionnel Documents
Culture Documents
It's possible to get these properties :Syntax for creating and describing object in QTP : Set Variable_Name = Description.Create Variable_Name("property").value = "properties from APP" Variable_Name("property").value = "properties from APP" Here is an example for describing googleSearchText,googleSearchBtn : Set googleSearchText = Description.Create googleSearchText("micclass").value = "WebEdit" googleSearchText("type").value = "text" googleSearchText("name").value = "q" Set googleSearchBtn = Description.Create googleSearchBtn("micclass").value = "WebButton" googleSearchBtn("name").value = "Google Search" Step 5: Now we are going to put all the created objects together to use it. So far we created a Any page object, Google search text box and Google Search button. To use all the object together the syntax is: anyPage.Type of object(Object Name).command "what we want to search" Example anyPage.WebEdit(googleSearchText).Set "Bytetips QTP Tutorial" This is the Final script we created using descriptive programing. This script will start Internet Explorer and navigate to Google and search for the text provided in the text field. You can copy-paste this script inside qtp to see how this thing works.
Second way to do Descriptive Programming in QTP: The first way is a bit long process. We can do inline descriptive programing to shorten the script. Step 1: At first we are going to run Internet Explorer. In QTP we use systemutil.Run command to run any program. To do so the syntax will be: systemutil.Run "The program we want to run", "the website Address" Example for opening www.google.com systemutil.Run "iexplore.exe", "www.google.com" Step 2: Now we are going to declare variable for this example we are using : anyPage = For Describing a browser and page. For Example: Dim anyPage Step 3: Then We are going to initialize the anyPage variable. We are going to set it to run on any page. Look at the code below: Set anyPage = Browser("micclass:=Browser").Page("micclass:=Page") The purpose of initializing this into variable is to shortening the code. Step 4: In this step we are going create and describe the objects. This time Syntax for creating and describing object would be : Page object.Type of object(Object Name).command "what we want to search" For Example : anyPage.WebEdit("micclass:=WebEdit","name:=q","type:=text").Set "Bytetips QTP Tutorial" Step 5: Now we can put all our code together Look at the code below: systemutil.Run "iexplore.exe", "www.google.com" Dim anyPage Set anyPage = Browser("micclass:=Browser").Page("micclass:=Page") anyPage.WebEdit("micclass:=WebEdit","name:=q","type:=text").Set "Bytetips QTP Tutorial" anyPage.WebButton("micclass:=WebButton","name:=Google Search").Click